use wrapper for grouped theorem generation

This commit is contained in:
Maximilian Keßler 2022-01-21 13:39:06 +01:00
parent 7996b7b537
commit 10458e55ed
2 changed files with 24 additions and 64 deletions

View file

@ -1831,7 +1831,7 @@
% \end{macrocode} % \end{macrocode}
% \end{macro} % \end{macro}
% %
% \subsection{Iterating over powersets} % \subsection{Iterating over powersets}
% For generating the different variants of a theorem family, % For generating the different variants of a theorem family,
% we need to iterate over over the powerset of some list. % we need to iterate over over the powerset of some list.
% This is a collection of hacks that perform exactly this, % 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} % \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} % \marg{groups clist}\marg{theorem name}\marg{thmtools keys}
% \end{syntax} % \end{syntax}
% %
@ -1947,7 +1947,7 @@
% command of \pkg{thmtools}. % command of \pkg{thmtools}.
% %
% \begin{macrocode} % \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} % \end{macrocode}
% First, set local variables to default values and store current name. % First, set local variables to default values and store current name.
@ -2018,6 +2018,9 @@
% \groupthm_new_grouped_theorem:nnnn, % \groupthm_new_grouped_theorem:nnnn,
% \groupthm_new_grouped_theorem:nVVV, % \groupthm_new_grouped_theorem:nVVV,
% \groupthm_new_grouped_theorem:xVnn % \groupthm_new_grouped_theorem:xVnn
% \groupthm_provide_grouped_theorem:nnnn,
% \groupthm_provide_grouped_theorem:nVVV,
% \groupthm_provide_grouped_theorem:xVnn
% } % }
% \begin{syntax} % \begin{syntax}
% \cs{groupthm_new_grouped_theorem:nnnn}\marg{environment name} % \cs{groupthm_new_grouped_theorem:nnnn}\marg{environment name}
@ -2025,23 +2028,14 @@
% \end{syntax} % \end{syntax}
% %
% \begin{macrocode} % \begin{macrocode}
\cs_new:Npn \groupthm_new_grouped_theorem:nnnn #1 #2 #3 #4 \@@_define_multiple:nnnNNnn
{ { new, provide }
% \end{macrocode} { grouped ~ theorem }
% Note that the next comparison depends on \pkg{thmtools} declaring { ##1 }
% environments, and that \LaTeX\ handles environments called with the \error
% |\begin{environment}| syntax by calling |\environment| subsequently. \@@_define_theorem:nnnn
% \begin{macrocode} { groupthm_#1_grouped_theorem:nnnn }
\cs_if_exist:cTF { #1 } { { ##1 } { ##2 } { ##3 } { ##4 } }
{
\msg_error:nnnnn { groupthm } { wrong ~ definition }
{ grouped ~ theorem } { #1 } { already }
}
{
\@@_declare_grouped_theorem_aux: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 { n V V V }
% \end{macrocode} % \end{macrocode}
% We need this extra variant here for the generation of theorem families later: % We need this extra variant here for the generation of theorem families later:
@ -2051,26 +2045,6 @@
% \end{macro} % \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 % The star variants of these that add the \texttt{unnumbered} group
% are straightforward: % are straightforward:

View file

@ -367,7 +367,6 @@
{ {
\groupthm_declare_group_rule:nnnn {#1} {#2} {#3} {#4} \groupthm_declare_group_rule:nnnn {#1} {#2} {#3} {#4}
} }
% \subsection{Iterating over powersets}
\clist_new:N \l__powerset_copied_clist \clist_new:N \l__powerset_copied_clist
\seq_new:N \l__powerset_saved_seq \seq_new:N \l__powerset_saved_seq
\cs_generate_variant:Nn \clist_remove_all:Nn { N V } \cs_generate_variant:Nn \clist_remove_all:Nn { N V }
@ -417,7 +416,7 @@
#1 { \tl_use:N \l__groupthm_name_tl } #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_clear:N \l__groupthm_prefix_tl
\tl_set:Nn \l__groupthm_name_tl { #3 } \tl_set:Nn \l__groupthm_name_tl { #3 }
@ -445,29 +444,16 @@
\l__groupthm_thmtools_clist \l__groupthm_thmtools_clist
{ #1 } { #1 }
} }
\cs_new:Npn \groupthm_new_grouped_theorem:nnnn #1 #2 #3 #4 \__groupthm_define_multiple:nnnNNnn
{ { new, provide }
\cs_if_exist:cTF { #1 } { grouped ~ theorem }
{ { ##1 }
\msg_error:nnnnn { groupthm } { wrong ~ definition } \error
{ grouped ~ theorem } { #1 } { already } \__groupthm_define_theorem:nnnn
} { groupthm_#1_grouped_theorem:nnnn }
{ { { ##1 } { ##2 } { ##3 } { ##4 } }
\__groupthm_declare_grouped_theorem_aux: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 { n V V V }
\cs_generate_variant:Nn \groupthm_new_grouped_theorem:nnnn { x V n n } \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 \cs_new:Npn \groupthm_new_grouped_theorem_star:nnnn #1 #2 #3 #4
{ {
\groupthm_new_grouped_theorem:nnnn \groupthm_new_grouped_theorem:nnnn