From 5c45b89b525a6bb153a5db9ebdb33a8ba2c3991d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Wed, 19 Jan 2022 15:21:14 +0100 Subject: [PATCH] dump --- doc/environments/groupthm/groupthm.dtx | 19 +++- doc/environments/groupthm/groupthm.tdo | 2 +- src/environments/groupthm.pysty3 | 149 +++++++++++++++++-------- 3 files changed, 117 insertions(+), 53 deletions(-) diff --git a/doc/environments/groupthm/groupthm.dtx b/doc/environments/groupthm/groupthm.dtx index b894872..a35faf5 100644 --- a/doc/environments/groupthm/groupthm.dtx +++ b/doc/environments/groupthm/groupthm.dtx @@ -12,6 +12,7 @@ % https://www.latex-project.org/lppl.txt % % ----------------------------------------------------------------------- +%\ProvidesExplPackage{groupthm}{2022/01/17}{0.0.1}{Grouped theorems.} % %<*driver> \documentclass[full,kernel]{l3doc} @@ -54,7 +55,12 @@ % \begin{itemize} % \item Inheritance % \item Appending to groups -% \item Generation + parsing of families +% \item default group integration +% \item better error message to avoid low level tex errors in any case +% \item potentially: detection of star / nonstar misuse +% \item add command to define group rule for all existing groups +% \item various info commands on defined groups? +% \item debugging information? % \end{itemize} % A central thing in \LaTeX is the usage of \enquote{theorems}. % With \enquote{theorems} we actually mean \enquote{environments} that typically @@ -930,11 +936,13 @@ %<@@=groupthm> % \end{macrocode} % +% +% +% % \subsection{Dependencies} -% Identify package -% \begin{macrocode} -\ProvidesExplPackage{groupthm}{2022/01/17}{0.0.1}{Grouped theorems.} -% \end{macrocode} +% +% +% % First, we import other packages on which we rely on, and % set up some private wrappers around these. % \begin{macrocode} @@ -3367,4 +3375,3 @@ % % % \newpage -% \PrintIndex diff --git a/doc/environments/groupthm/groupthm.tdo b/doc/environments/groupthm/groupthm.tdo index 31f02cd..944bf21 100644 --- a/doc/environments/groupthm/groupthm.tdo +++ b/doc/environments/groupthm/groupthm.tdo @@ -1,5 +1,5 @@ \contentsline {todo}{\color@fb@x {}{black}{}{orange}{\leavevmode {\color {orange}o}}\ insert code example output}{4}{section*.3}% -\contentsline {todo}{\color@fb@x {}{black}{}{orange}{\leavevmode {\color {orange}o}}\ code}{4}{section*.4}% +\contentsline {todo}{\color@fb@x {}{black}{}{orange}{\leavevmode {\color {orange}o}}\ code}{5}{section*.4}% \contentsline {todo}{\color@fb@x {}{black}{}{red!40}{\leavevmode {\color {red!40}o}}\ Add reference.}{7}{section*.5}% \contentsline {todo}{\color@fb@x {}{black}{}{red!40}{\leavevmode {\color {red!40}o}}\ Add reference.}{7}{section*.6}% \contentsline {todo}{\color@fb@x {}{black}{}{red!40}{\leavevmode {\color {red!40}o}}\ Add reference.}{8}{section*.7}% diff --git a/src/environments/groupthm.pysty3 b/src/environments/groupthm.pysty3 index cdfe3c9..06e575a 100644 --- a/src/environments/groupthm.pysty3 +++ b/src/environments/groupthm.pysty3 @@ -243,6 +243,10 @@ __HEADER__(Grouping theorems for easier customization.) \@@_declare_theorem_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 } } + +%%% Documented until here + + %%% Grouped Theorems \cs_new:Npn \group_use:n #1 @@ -301,6 +305,24 @@ __HEADER__(Grouping theorems for easier customization.) \cs_generate_variant:Nn \new_grouped_theorem:nnnn { n V V V } \cs_generate_variant:Nn \new_grouped_theorem:nnnn { x V n n } +\cs_new:Npn \groupthm_provide_grouped_theorem:nnnn + { + \cs_if_exist:cF { #1 } + { + \@@_groupthm_declare_grouped_theorem_aux:nnnn + { #1 } { #2 } { #3 } { #4 } + } + } + + +\cs_new:Npn \groupthm_new_theorem:nnnn #1 #2 #3 #4 + { + \groupthm_new_grouped_theorem:nnnn + { #1 } { #2 } { #3 } { #4 } + \groupthm_new_grouped_theorem:nnnn + { #1* } { #2, starred } { #3 } { #4 } + } + % keys, subgroup \cs_new:Npn \@@_set_normalized_keys:nnn #1 #2 #3 @@ -327,23 +349,17 @@ __HEADER__(Grouping theorems for easier customization.) } +\cs_new:Npn \groupthm_provide_theorem_star:nnnn #1 #2 #3 #4 +{ + \groupthm_provide_theorem:nnnn + { #1 } { #2, unnumbered } { #3 } { #4 } +} + % envname, keys \cs_new:Npn \new_grouped_theorem_from_keys:nn #1 #2 { \@@_set_normalized_keys { #2 } { groupedtheorem } { #1 } - % Construct name - \tl_if_eq:NnTF \l_@@_key_name_tl { \c_novalue_tl } - { - \tl_set:Nx \l_@@_name_tl - { - \text_titlecase_first:n {#1} - } - } - { - \tl_set_eq:NN \l_@@_name_tl \l_@@_key_name_tl - } - \new_grouped_theorem:nVVV { #1 } \l_@@_key_group_clist @@ -357,6 +373,12 @@ __HEADER__(Grouping theorems for easier customization.) } +\groupthm_new_grouped_theorem_from_keys:nn +{ + +} + + %% Rules for different theorem groups \cs_generate_variant:Nn \hook_gset_rule:nnnn { n n V n } @@ -364,19 +386,25 @@ __HEADER__(Grouping theorems for easier customization.) % hook group1 relation group2 \cs_new:Npn \declare_theorem_group_rule:nnnn #1 #2 #3 #4 { - \tl_set:Nx \l_@@_relation_tl { \tl_trim_spaces:n { #3 } } + \str_set:Nx \l_tmpa_str { \tl_trim_spaces:n { #3 } } - \tl_if_eq:nnT { higher } { #3 } + \str_if_eq:VnT \l_tmpa_str { higher } { - \tl_set:Nn \l_@@_relation_tl { after } + \str_set:Nn \l_tmpa_tl { after } } - \tl_if_eq:nnT { lower } { #3 } + \str_if_eq:VnT \l_tmpa_str{ lower } { - \tl_set:Nn \l_@@_relation_tl { before } + \str_set:Nn \l_tmpa_tl { before } } - \hook_gset_rule:nnVn {#1} {#2} \l_@@_relation_tl {#4} + \str_if_eq:nnTF { #1 } { ?? } + { + \hook_gset_rule:nnVn {??} {#2} \l_tmpa_tl {#4} + } + { + \hook_gset_rule:nnVn { @@ / #1 } {#2} \l_tmpa_tl {#4} + } } % hook, group1, relation, group2 @@ -410,6 +438,25 @@ __HEADER__(Grouping theorems for easier customization.) \ExplSyntaxOn +% envname, groups, name, thmtools list, extra groups (not in powerset) +\cs_new:Npn \@@_new_grouped_theorem_family_aux:nnnnnn + { + \clist_set:Nn \l_tmpa_clist { #2 } + \powerset_clist_foreach:Nn \l_tmpa_clist + { + \clist_set_eq:NN \l_@@_group_clist \l_tmpa_clist + \clist_put_right:Nn \l_@@_group_clist { #5 } + \__sort_group_names: + + \use:c{groupthm_#6_grouped_theorem:xVnn} + {__#1__groups_\clist_use:Nn \l_@@_group_clist {_}} + \l_@@_group_clist + { #3 } + { #4 } + } + } + + % envname, name, thmtools, list of groups \cs_new:Npn \generate_theorem_variants:nnnn #1 #2 #3 #4 { @@ -428,6 +475,18 @@ __HEADER__(Grouping theorems for easier customization.) \cs_generate_variant:Nn \generate_theorem_variants:nnnn { n V V V } +\cs_new:Npn \groupthm_new_grouped_theorem_family_from_keys:nn #1 #2 +{ + \@@_set_normalized_keys:nn { #1 } { #2 } + \groupthm_new_grouped_theorem_family:nVVV + { #2 } + \l_@@_groups_clist + \l_@@_name_tl + \l_@@_thmtools_clist +} + + + % envname, keys \cs_new:Npn \generate_theorem_variants_from_keys:nn #1 #2 { @@ -463,41 +522,39 @@ __HEADER__(Grouping theorems for easier customization.) %%% Theorem variants declaration / parsing \cs_new:Npn \add_theorem_to_group:n #1 { - \clist_put_left:Nn \l_@@_group_clist { #1 } + \bool_if:NTF \l_@@_in_family_options_environment_bool + { + \clist_put_left:Nn \l_@@_group_clist { #1 } + } + { + \msg_error:nn { groupthm } { misuse ~ add ~ theorem ~ to ~ group } + } } -% envname, signature, definition, starred? -\cs_new:Npn \__new_theorem_variant_parser_aux:nnnn #1 #2 #3 #4 +% envname, signature, definition, always groups, backend +\cs_new:Npn \__new_theorem_variant_parser_aux:nnnn #1 #2 #3 #4 #5 { - \exp_args:Nx\NewDocumentEnvironment - { - #1\IfBooleanT{#4}{*} - } - {#2} - { - \clist_clear:N \l_@@_group_clist - - #3 - - \IfBooleanT{#4} + \use:c{ #5 DocumentEnvironment } + { #1 } + { #2 } { - \add_theorem_to_group:n { starred } + \clist_clear:N \l_@@_group_clist + + #3 + + \clist_put_right:NV \l_@@_group_clist { #4 } + \__sort_group_names: + \begin { __#1__groups_ \clist_use:Nn \l_@@_group_clist { _ } } } - \__sort_group_names: - \begin{__#1__groups_\clist_use:Nn \l_@@_group_clist{_}} - } - { - \clist_clear:N \l_@@_group_clist - - #3 - - \IfBooleanT{#4} { - \add_theorem_to_group:n { starred } + \clist_clear:N \l_@@_group_clist + + #3 + + \clist_put_right:NV \l_@@_group_clist { #4 } + \__sort_group_names: + \end { __#1__groups_ \clist_use:Nn \l_@@_group_clist { _ } } } - \__sort_group_names: - \end{__#1__groups_\clist_use:Nn \l_@@_group_clist{_}} - } } % envname, signature, definition