From ddf4957b936378d6f47e0122d4314e52ad6711df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Tue, 18 Jan 2022 13:23:44 +0100 Subject: [PATCH] fix some more bugs --- doc/environments/groupthm/groupthm.dtx | 66 +++++---- doc/environments/groupthm/groupthm.sty | 179 ++++++++++++++++++++++++- 2 files changed, 216 insertions(+), 29 deletions(-) diff --git a/doc/environments/groupthm/groupthm.dtx b/doc/environments/groupthm/groupthm.dtx index 3cdc246..d765aba 100644 --- a/doc/environments/groupthm/groupthm.dtx +++ b/doc/environments/groupthm/groupthm.dtx @@ -858,6 +858,7 @@ % \begin{macrocode} \cs_new:Npn \@@_thmtools_declare_theorem:nn #1 #2 { + \tl_log:n { Declaring ~ thmtools ~ theorem ~ #2 } \declaretheorem [ #1 ] { #2 } } \cs_generate_variant:Nn \@@_thmtools_declare_theorem:nn { V n } @@ -1201,7 +1202,7 @@ \cs_new:Npn \@@_sort_theorem_group_names: { \hook_gremove_code:nn { @@/groupsort }{*} - \clist_map_function:NN \l_@@_group_clist \__add_to_sort_hook:n + \clist_map_function:NN \l_@@_group_clist \@@_add_to_sort_hook:n \clist_clear:N \l_@@_group_clist \hook_use:n { @@/groupsort } } @@ -1808,7 +1809,12 @@ % % % -% \begin{macro}{\groupthm_new_grouped_theorem:nnnn,\groupthm_new_grouped_theorem:nVVV} +% \begin{macro} +% { +% \groupthm_new_grouped_theorem:nnnn, +% \groupthm_new_grouped_theorem:nVVV, +% \groupthm_new_grouped_theorem:xVnn +% } % \begin{syntax} % \cs{groupthm_new_grouped_theorem:nnnn}\marg{environment name} % \marg{groups clist}\marg{theorem name}\marg{thmtools keys} @@ -1834,6 +1840,10 @@ } \cs_generate_variant:Nn \groupthm_new_grouped_theorem:nnnn { n V V V } % \end{macrocode} +% We need this extra variant here for the generation of theorem families later: +% \begin{macrocode} +\cs_generate_variant:Nn \groupthm_new_grouped_theorem:nnnn { x V n n } +% \end{macrocode} % \end{macro} % % @@ -2221,7 +2231,7 @@ % The \meta{generation type} can be either \texttt{new} or \texttt{provide}, % depending on which backend for grouped theorem generation to use % \begin{macrocode} -\cs_new:Npn \@@_declare_grouped_theorem_family_aux:nnnnnn +\cs_new:Npn \@@_declare_grouped_theorem_family_aux:nnnnnn #1 #2 #3 #4 #5 #6 { % \end{macrocode} % Make a local copy of the \meta{groups clist} argument, @@ -2240,7 +2250,7 @@ % This sorting is necessary so that for each theorem family and set of groups, % the generated name will be unique: % \begin{macrocode} - \__sort_group_names: + \@@_sort_theorem_group_names: % \end{macrocode} % Now just declare the grouped theorem, passing the corresponding arguments and using % specified \texttt{\#6} as backend. @@ -2436,10 +2446,10 @@ % \begin{macrocode} \cs_new:Npn \groupthm_new_grouped_theorem_family_from_keys:nn #1 #2 { - \@@_set_normalized_keys:nn { #1 } { #2 } + \@@_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 } \groupthm_new_grouped_theorem_family:nVVV { #2 } - \l_@@_groups_clist + \l_@@_group_clist \l_@@_name_tl \l_@@_thmtools_clist } @@ -2458,10 +2468,10 @@ % \begin{macrocode} \cs_new:Npn \groupthm_provide_grouped_theorem_family_from_keys:nn #1 #2 { - \@@_set_normalized_keys:nn { #1 } { #2 } + \@@_set_normalized_keys:nnn { #1 } {groupedtheorem} { #2 } \groupthm_provide_grouped_theorem_family:nVVV { #2 } - \l_@@_groups_clist + \l_@@_group_clist \l_@@_name_tl \l_@@_thmtools_clist } @@ -2480,10 +2490,10 @@ % \begin{macrocode} \cs_new:Npn \groupthm_new_grouped_theorem_family_star_from_keys:nn #1 #2 { - \@@_set_normalized_keys:nn { #1 } { #2 } + \@@_set_normalized_keys:nnn { #1 } { groupedtheorem }{ #2 } \groupthm_new_grouped_theorem_family_star:nVVV { #2 } - \l_@@_groups_clist + \l_@@_group_clist \l_@@_name_tl \l_@@_thmtools_clist } @@ -2502,10 +2512,10 @@ % \begin{macrocode} \cs_new:Npn \groupthm_provide_grouped_theorem_family_star_from_keys:nn #1 #2 { - \@@_set_normalized_keys:nn { #1 } { #2 } + \@@_set_normalized_keys:nnn { #1 } { groupedtheorem }{ #2 } \groupthm_provide_grouped_theorem_family_star:nVVV { #2 } - \l_@@_groups_clist + \l_@@_group_clist \l_@@_name_tl \l_@@_thmtools_clist } @@ -2524,10 +2534,10 @@ % \begin{macrocode} \cs_new:Npn \groupthm_new_theorem_family_from_keys:nn #1 #2 { - \@@_set_normalized_keys:nn { #1 } { #2 } + \@@_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 } \groupthm_new_theorem_family:nVVV { #2 } - \l_@@_groups_clist + \l_@@_group_clist \l_@@_name_tl \l_@@_thmtools_clist } @@ -2546,10 +2556,10 @@ % \begin{macrocode} \cs_new:Npn \groupthm_provide_theorem_family_from_keys:nn #1 #2 { - \@@_set_normalized_keys:nn { #1 } { #2 } + \@@_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 } \groupthm_provide_theorem_family:nVVV { #2 } - \l_@@_groups_clist + \l_@@_group_clist \l_@@_name_tl \l_@@_thmtools_clist } @@ -2568,10 +2578,10 @@ % \begin{macrocode} \cs_new:Npn \groupthm_new_theorem_family_star_from_keys:nn #1 #2 { - \@@_set_normalized_keys:nn { #1 } { #2 } + \@@_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 } \groupthm_new_theorem_family_star:nVVV { #2 } - \l_@@_groups_clist + \l_@@_group_clist \l_@@_name_tl \l_@@_thmtools_clist } @@ -2590,10 +2600,10 @@ % \begin{macrocode} \cs_new:Npn \groupthm_provide_theorem_family_star_from_keys:nn #1 #2 { - \@@_set_normalized_keys:nn { #1 } { #2 } + \@@_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 } \groupthm_provide_theorem_family_star:nVVV { #2 } - \l_@@_groups_clist + \l_@@_group_clist \l_@@_name_tl \l_@@_thmtools_clist } @@ -2617,10 +2627,10 @@ { \IfBooleanTF { #1 } { - \groupthm_new_grouped_theorem_family_from_keys:nn { #2 } { #3 } + \groupthm_new_grouped_theorem_family_star_from_keys:nn { #2 } { #3 } } { - \groupthm_new_grouped_theorem_family_star_from_keys:nn { #2 } { #3 } + \groupthm_new_grouped_theorem_family_from_keys:nn { #2 } { #3 } } } % \end{macrocode} @@ -2640,10 +2650,10 @@ { \IfBooleanTF { #1 } { - \groupthm_provide_grouped_theorem_family_from_keys:nn { #2 } { #3 } + \groupthm_provide_grouped_theorem_family_star_from_keys:nn { #2 } { #3 } } { - \groupthm_provide_grouped_theorem_family_star_from_keys:nn { #2 } { #3 } + \groupthm_provide_grouped_theorem_family_from_keys:nn { #2 } { #3 } } } % \end{macrocode} @@ -2662,10 +2672,10 @@ { \IfBooleanTF { #1 } { - \groupthm_new_theorem_family_from_keys:nn { #2 } { #3 } + \groupthm_new_theorem_family_star_from_keys:nn { #2 } { #3 } } { - \groupthm_new_theorem_family_star_from_keys:nn { #2 } { #3 } + \groupthm_new_theorem_family_from_keys:nn { #2 } { #3 } } } % \end{macrocode} @@ -2685,10 +2695,10 @@ { \IfBooleanTF { #1 } { - \groupthm_provide_theorem_family_from_keys:nn { #2 } { #3 } + \groupthm_provide_theorem_family_star_from_keys:nn { #2 } { #3 } } { - \groupthm_provide_theorem_family_star_from_keys:nn { #2 } { #3 } + \groupthm_provide_theorem_family_from_keys:nn { #2 } { #3 } } } % \end{macrocode} diff --git a/doc/environments/groupthm/groupthm.sty b/doc/environments/groupthm/groupthm.sty index a0cf7c4..0de90f2 100644 --- a/doc/environments/groupthm/groupthm.sty +++ b/doc/environments/groupthm/groupthm.sty @@ -26,6 +26,7 @@ \RequirePackage{thmtools} \cs_new:Npn \__groupthm_thmtools_declare_theorem:nn #1 #2 { + \tl_log:n { Declaring ~ thmtools ~ theorem ~ #2 } \declaretheorem [ #1 ] { #2 } } \cs_generate_variant:Nn \__groupthm_thmtools_declare_theorem:nn { V n } @@ -139,7 +140,7 @@ \cs_new:Npn \__groupthm_sort_theorem_group_names: { \hook_gremove_code:nn { __groupthm/groupsort }{*} - \clist_map_function:NN \l__groupthm_group_clist \__add_to_sort_hook:n + \clist_map_function:NN \l__groupthm_group_clist \__groupthm_add_to_sort_hook:n \clist_clear:N \l__groupthm_group_clist \hook_use:n { __groupthm/groupsort } } @@ -414,6 +415,7 @@ } } \cs_generate_variant:Nn \groupthm_new_grouped_theorem:nnnn { n V V V } +\cs_generate_variant:Nn \groupthm_new_grouped_theorem:nnnn { x V n n } \cs_new:Npn \groupthm_provide_grouped_theorem:nnnn #1 #2 #3 #4 { \cs_if_exist:cF { #1 } @@ -579,6 +581,181 @@ \groupthm_provide_theorem_from_keys:nn { #2 } { #3 } } } +\cs_new:Npn \__groupthm_declare_grouped_theorem_family_aux:nnnnnn #1 #2 #3 #4 #5 #6 + { + \clist_set:Nn \l_tmpa_clist { #2 } + \powerset_clist_foreach:Nn \l_tmpa_clist + { + \clist_set_eq:NN \l__groupthm_group_clist \l_tmpa_clist + \clist_put_right:Nn \l__groupthm_group_clist { #5 } + \__groupthm_sort_theorem_group_names: + \use:c{groupthm_#6_grouped_theorem:xVnn} + {__#1__groups_\clist_use:Nn \l__groupthm_group_clist {_}} + \l__groupthm_group_clist + { #3 } + { #4 } + } + } +\cs_new:Npn \groupthm_new_grouped_theorem_family:nnnn #1 #2 #3 #4 + { + \__groupthm_declare_grouped_theorem_family_aux:nnnnnn + { #1 } { #2 } { #3 } { #4 } { } { new } + } +\cs_generate_variant:Nn \groupthm_new_grouped_theorem_family:nnnn { n V V V } +\cs_new:Npn \groupthm_provide_grouped_theorem_family:nnnn #1 #2 #3 #4 + { + \__groupthm_declare_grouped_theorem_family_aux:nnnnnn + { #1 } { #2 } { #3 } { #4 } { } { provide } + } +\cs_generate_variant:Nn \groupthm_provide_grouped_theorem_family:nnnn { n V V V } +\cs_new:Npn \groupthm_new_grouped_theorem_family_star:nnnn #1 #2 #3 #4 + { + \__groupthm_declare_grouped_theorem_family_aux:nnnnnn + { #1 } { #2 } { #3 } { #4 } { unnumbered } { new } + } +\cs_generate_variant:Nn \groupthm_new_grouped_theorem_family_star:nnnn { n V V V } +\cs_new:Npn \groupthm_provide_grouped_theorem_family_star:nnnn #1 #2 #3 #4 + { + \__groupthm_declare_grouped_theorem_family_aux:nnnnnn + { #1 } { #2 } { #3 } { #4 } { } { provide } + } +\cs_generate_variant:Nn \groupthm_provide_grouped_theorem_family_star:nnnn { n V V V } +\cs_new:Npn \groupthm_new_theorem_family:nnnn #1 #2 #3 #4 + { + \__groupthm_declare_grouped_theorem_family_aux:nnnnnn + { #1 } { #2, starred } { #3 } { #4 } { } { new } + } +\cs_generate_variant:Nn \groupthm_new_theorem_family:nnnn { n V V V } +\cs_new:Npn \groupthm_provide_theorem_family:nnnn #1 #2 #3 #4 + { + \__groupthm_declare_grouped_theorem_family_aux:nnnnnn + { #1 } { #2, starred } { #3 } { #4 } { } { provide } + } +\cs_generate_variant:Nn \groupthm_provide_theorem_family:nnnn { n V V V } +\cs_new:Npn \groupthm_new_theorem_family_star:nnnn #1 #2 #3 #4 + { + \__groupthm_declare_grouped_theorem_family_aux:nnnnnn + { #1 } { #2, starred } { #3 } { #4 } { unnumbered } { new } + } +\cs_generate_variant:Nn \groupthm_new_theorem_family_star:nnnn { n V V V } +\cs_new:Npn \groupthm_provide_theorem_family_star:nnnn #1 #2 #3 #4 + { + \__groupthm_declare_grouped_theorem_family_aux:nnnnnn + { #1 } { #2, starred } { #3 } { #4 } { } { provide } + } +\cs_generate_variant:Nn \groupthm_provide_theorem_family_star:nnnn { n V V V } +\cs_new:Npn \groupthm_new_grouped_theorem_family_from_keys:nn #1 #2 + { + \__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 } + \groupthm_new_grouped_theorem_family:nVVV + { #2 } + \l__groupthm_group_clist + \l__groupthm_name_tl + \l__groupthm_thmtools_clist + } +\cs_new:Npn \groupthm_provide_grouped_theorem_family_from_keys:nn #1 #2 + { + \__groupthm_set_normalized_keys:nnn { #1 } {groupedtheorem} { #2 } + \groupthm_provide_grouped_theorem_family:nVVV + { #2 } + \l__groupthm_group_clist + \l__groupthm_name_tl + \l__groupthm_thmtools_clist + } +\cs_new:Npn \groupthm_new_grouped_theorem_family_star_from_keys:nn #1 #2 + { + \__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem }{ #2 } + \groupthm_new_grouped_theorem_family_star:nVVV + { #2 } + \l__groupthm_group_clist + \l__groupthm_name_tl + \l__groupthm_thmtools_clist + } +\cs_new:Npn \groupthm_provide_grouped_theorem_family_star_from_keys:nn #1 #2 + { + \__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem }{ #2 } + \groupthm_provide_grouped_theorem_family_star:nVVV + { #2 } + \l__groupthm_group_clist + \l__groupthm_name_tl + \l__groupthm_thmtools_clist + } +\cs_new:Npn \groupthm_new_theorem_family_from_keys:nn #1 #2 + { + \__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 } + \groupthm_new_theorem_family:nVVV + { #2 } + \l__groupthm_group_clist + \l__groupthm_name_tl + \l__groupthm_thmtools_clist + } +\cs_new:Npn \groupthm_provide_theorem_family_from_keys:nn #1 #2 + { + \__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 } + \groupthm_provide_theorem_family:nVVV + { #2 } + \l__groupthm_group_clist + \l__groupthm_name_tl + \l__groupthm_thmtools_clist + } +\cs_new:Npn \groupthm_new_theorem_family_star_from_keys:nn #1 #2 + { + \__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 } + \groupthm_new_theorem_family_star:nVVV + { #2 } + \l__groupthm_group_clist + \l__groupthm_name_tl + \l__groupthm_thmtools_clist + } +\cs_new:Npn \groupthm_provide_theorem_family_star_from_keys:nn #1 #2 + { + \__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 } + \groupthm_provide_theorem_family_star:nVVV + { #2 } + \l__groupthm_group_clist + \l__groupthm_name_tl + \l__groupthm_thmtools_clist + } +\NewDocumentCommand{\NewGroupedTheoremFamily}{s O{} m} + { + \IfBooleanTF { #1 } + { + \groupthm_new_grouped_theorem_family_star_from_keys:nn { #2 } { #3 } + } + { + \groupthm_new_grouped_theorem_family_from_keys:nn { #2 } { #3 } + } + } +\NewDocumentCommand{\ProvideGroupedTheoremFamily}{s O{} m} + { + \IfBooleanTF { #1 } + { + \groupthm_provide_grouped_theorem_family_star_from_keys:nn { #2 } { #3 } + } + { + \groupthm_provide_grouped_theorem_family_from_keys:nn { #2 } { #3 } + } + } +\NewDocumentCommand{\NewTheoremFamily}{s O{} m} + { + \IfBooleanTF { #1 } + { + \groupthm_new_theorem_family_star_from_keys:nn { #2 } { #3 } + } + { + \groupthm_new_theorem_family_from_keys:nn { #2 } { #3 } + } + } +\NewDocumentCommand{\ProvideTheoremFamily}{s O{} m} + { + \IfBooleanTF { #1 } + { + \groupthm_provide_theorem_family_star_from_keys:nn { #2 } { #3 } + } + { + \groupthm_provide_theorem_family_from_keys:nn { #2 } { #3 } + } + } \endinput %% %% End of file `groupthm.sty'.