From 10458e55ed3b58d80cd048df3793542a67f62da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Fri, 21 Jan 2022 13:39:06 +0100 Subject: [PATCH] use wrapper for grouped theorem generation --- doc/environments/groupthm/groupthm.dtx | 56 +++++++------------------- doc/environments/groupthm/groupthm.sty | 32 +++++---------- 2 files changed, 24 insertions(+), 64 deletions(-) diff --git a/doc/environments/groupthm/groupthm.dtx b/doc/environments/groupthm/groupthm.dtx index 66314b5..9eb2429 100644 --- a/doc/environments/groupthm/groupthm.dtx +++ b/doc/environments/groupthm/groupthm.dtx @@ -1831,7 +1831,7 @@ % \end{macrocode} % \end{macro} % - % \subsection{Iterating over powersets} +% \subsection{Iterating over powersets} % For generating the different variants of a theorem family, % we need to iterate over over the powerset of some list. % This is a collection of hacks that perform exactly this, @@ -1936,9 +1936,9 @@ % % % -% \begin{macro}{\@@_declare_grouped_theorem_aux:nnnn} +% \begin{macro}{\@@_define_theorem:nnnn} % \begin{syntax} -% \cs{@@_declare_grouped_theorem_aux:nnnn}\marg{environment name} +% \cs{@@_define_theorem:nnnn}\marg{environment name} % \marg{groups clist}\marg{theorem name}\marg{thmtools keys} % \end{syntax} % @@ -1947,7 +1947,7 @@ % command of \pkg{thmtools}. % % \begin{macrocode} -\cs_new:Npn \@@_declare_grouped_theorem_aux:nnnn #1 #2 #3 #4 +\cs_new:Npn \@@_define_theorem:nnnn #1 #2 #3 #4 { % \end{macrocode} % First, set local variables to default values and store current name. @@ -2018,6 +2018,9 @@ % \groupthm_new_grouped_theorem:nnnn, % \groupthm_new_grouped_theorem:nVVV, % \groupthm_new_grouped_theorem:xVnn +% \groupthm_provide_grouped_theorem:nnnn, +% \groupthm_provide_grouped_theorem:nVVV, +% \groupthm_provide_grouped_theorem:xVnn % } % \begin{syntax} % \cs{groupthm_new_grouped_theorem:nnnn}\marg{environment name} @@ -2025,23 +2028,14 @@ % \end{syntax} % % \begin{macrocode} -\cs_new:Npn \groupthm_new_grouped_theorem:nnnn #1 #2 #3 #4 - { -% \end{macrocode} -% Note that the next comparison depends on \pkg{thmtools} declaring -% environments, and that \LaTeX\ handles environments called with the -% |\begin{environment}| syntax by calling |\environment| subsequently. -% \begin{macrocode} - \cs_if_exist:cTF { #1 } - { - \msg_error:nnnnn { groupthm } { wrong ~ definition } - { grouped ~ theorem } { #1 } { already } - } - { - \@@_declare_grouped_theorem_aux:nnnn - { #1 } { #2 } { #3 } { #4 } - } - } +\@@_define_multiple:nnnNNnn + { new, provide } + { grouped ~ theorem } + { ##1 } + \error + \@@_define_theorem:nnnn + { groupthm_#1_grouped_theorem:nnnn } + { { ##1 } { ##2 } { ##3 } { ##4 } } \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: @@ -2051,26 +2045,6 @@ % \end{macro} % % -% \begin{macro}{\groupthm_provide_grouped_theorem:nnnn,\groupthm_provide_grouped_theorem:nVVV} -% -% \begin{macrocode} -\cs_new:Npn \groupthm_provide_grouped_theorem:nnnn #1 #2 #3 #4 - { -% \end{macrocode} -% Note that the next comparison depends on \pkg{thmtools} declaring -% environments, and that \LaTeX\ handles environments called with the -% |\begin{environment}| syntax by calling |\environment| subsequently. -% \begin{macrocode} - \cs_if_exist:cF { #1 } - { - \@@_declare_grouped_theorem_aux:nnnn - { #1 } { #2 } { #3 } { #4 } - } - } -\cs_generate_variant:Nn \groupthm_provide_grouped_theorem:nnnn { n V V V } -% \end{macrocode} -% \end{macro} -% % % The star variants of these that add the \texttt{unnumbered} group % are straightforward: diff --git a/doc/environments/groupthm/groupthm.sty b/doc/environments/groupthm/groupthm.sty index 2bd03ad..865a70c 100644 --- a/doc/environments/groupthm/groupthm.sty +++ b/doc/environments/groupthm/groupthm.sty @@ -367,7 +367,6 @@ { \groupthm_declare_group_rule:nnnn {#1} {#2} {#3} {#4} } - % \subsection{Iterating over powersets} \clist_new:N \l__powerset_copied_clist \seq_new:N \l__powerset_saved_seq \cs_generate_variant:Nn \clist_remove_all:Nn { N V } @@ -417,7 +416,7 @@ #1 { \tl_use:N \l__groupthm_name_tl } } } -\cs_new:Npn \__groupthm_declare_grouped_theorem_aux:nnnn #1 #2 #3 #4 +\cs_new:Npn \__groupthm_define_theorem:nnnn #1 #2 #3 #4 { \tl_clear:N \l__groupthm_prefix_tl \tl_set:Nn \l__groupthm_name_tl { #3 } @@ -445,29 +444,16 @@ \l__groupthm_thmtools_clist { #1 } } -\cs_new:Npn \groupthm_new_grouped_theorem:nnnn #1 #2 #3 #4 - { - \cs_if_exist:cTF { #1 } - { - \msg_error:nnnnn { groupthm } { wrong ~ definition } - { grouped ~ theorem } { #1 } { already } - } - { - \__groupthm_declare_grouped_theorem_aux:nnnn - { #1 } { #2 } { #3 } { #4 } - } - } +\__groupthm_define_multiple:nnnNNnn + { new, provide } + { grouped ~ theorem } + { ##1 } + \error + \__groupthm_define_theorem:nnnn + { groupthm_#1_grouped_theorem:nnnn } + { { ##1 } { ##2 } { ##3 } { ##4 } } \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 } - { - \__groupthm_declare_grouped_theorem_aux:nnnn - { #1 } { #2 } { #3 } { #4 } - } - } -\cs_generate_variant:Nn \groupthm_provide_grouped_theorem:nnnn { n V V V } \cs_new:Npn \groupthm_new_grouped_theorem_star:nnnn #1 #2 #3 #4 { \groupthm_new_grouped_theorem:nnnn