higher abstraction for defining (re)new variants

new macro carries out all four definitions at once
    rename all groupthm_new_theorem_group... macros into
groupthm_new_group...
This commit is contained in:
Maximilian Keßler 2022-01-20 21:39:49 +01:00
parent 08323fdf48
commit 70ddae2307
3 changed files with 3469 additions and 143 deletions

3387
doc/environments/groupthm/5 Normal file

File diff suppressed because it is too large Load diff

View file

@ -712,13 +712,13 @@
% %
% \begin{function} % \begin{function}
% { % {
% \groupthm_new_theorem_group_from_keys:nn, % \groupthm_new_group_from_keys:nn,
% \groupthm_renew_theorem_group_from_keys:nn, % \groupthm_renew_group_from_keys:nn,
% \groupthm_provide_theorem_group_from_keys:nn, % \groupthm_provide_theorem_group_from_keys:nn,
% \groupthm_declare_theorem_group_from_keys:nn % \groupthm_declare_theorem_group_from_keys:nn
% } % }
% \begin{syntax} % \begin{syntax}
% \cs{groupthm_new_theorem_group_from_keys:nn}\marg{keys}\marg{theorem group} % \cs{groupthm_new_group_from_keys:nn}\marg{keys}\marg{theorem group}
% \end{syntax} % \end{syntax}
% %
% \LaTeX3 versions of \cs{NewTheoremGroup}, \cs{RenewTheoremGroup}, % \LaTeX3 versions of \cs{NewTheoremGroup}, \cs{RenewTheoremGroup},
@ -730,23 +730,23 @@
% %
% \begin{function} % \begin{function}
% { % {
% \groupthm_new_theorem_group:nnnnn, % \groupthm_new_group:nnnnn,
% \groupthm_renew_theorem_group:nnnnn, % \groupthm_renew_group:nnnnn,
% \groupthm_provide_theorem_group:nnnnn, % \groupthm_provide_theorem_group:nnnnn,
% \groupthm_declare_theorem_group:nnnnn, % \groupthm_declare_theorem_group:nnnnn,
% \groupthm_new_theorem_group:nVVVV, % \groupthm_new_group:nVVVV,
% \groupthm_renew_theorem_group:nVVVV, % \groupthm_renew_group:nVVVV,
% \groupthm_provide_theorem_group:nVVVV, % \groupthm_provide_theorem_group:nVVVV,
% \groupthm_declare_theorem_group:nVVVV % \groupthm_declare_theorem_group:nVVVV
% } % }
% \begin{syntax} % \begin{syntax}
% \cs{groupthm_new_theorem_group:nnnnn}\marg{theorem group}\marg{prefix tl} % \cs{groupthm_new_group:nnnnn}\marg{theorem group}\marg{prefix tl}
% \marg{suffix tl}\marg{mapname clist}\marg{thmtools clist} % \marg{suffix tl}\marg{mapname clist}\marg{thmtools clist}
% \end{syntax} % \end{syntax}
% %
% Non-keyval versions of % Non-keyval versions of
% \cs{groupthm_new_theorem_group_from_keys:nn}, % \cs{groupthm_new_group_from_keys:nn},
% \cs{groupthm_renew_theorem_group_from_keys:nn}, % \cs{groupthm_renew_group_from_keys:nn},
% \cs{groupthm_provide_theorem_group_from_keys:nn} % \cs{groupthm_provide_theorem_group_from_keys:nn}
% and % and
% \cs{groupthm_declare_theorem_group_from_keys:nn} % \cs{groupthm_declare_theorem_group_from_keys:nn}
@ -1501,7 +1501,7 @@
% \texttt{new}, \texttt{renew}, \texttt{provide} and \texttt{declare} variants % \texttt{new}, \texttt{renew}, \texttt{provide} and \texttt{declare} variants
% of the theorem group macro: % of the theorem group macro:
% %
% \begin{macro}{\groupthm_new_theorem_group:nnnnn, \groupthm_new_theorem_group:nVVVV} % \begin{macro}{\groupthm_new_group:nnnnn, \groupthm_new_group:nVVVV}
% %
% \begin{macrocode} % \begin{macrocode}
\cs_new:Npn \@@_define_aux:nnnNNNn #1 #2 #3 #4 #5 #6 #7 \cs_new:Npn \@@_define_aux:nnnNNNn #1 #2 #3 #4 #5 #6 #7
@ -1544,112 +1544,64 @@
} }
\cs_generate_variant:Nn \@@_define_aux:nnnNNNn { n n n c N N n } \cs_generate_variant:Nn \@@_define_aux:nnnNNNn { n n n c N N n }
\cs_new:Npn \groupthm_new_theorem_group:nnnnn #1 #2 #3 #4 #5 \cs_new:Npn \@@_define_list_aux:nnnNNnn #1 #2 #3 #4 #5 #6 #7
{ {
\cs_set:Npn \@@_map_aux:n ##1
{
\cs_new:cn { #6 }
{
\@@_define_aux:nnncNNn \@@_define_aux:nnncNNn
{ new } { ##1 }
{ #2 }
{ ####1 }
{ #3 }
#4
#5
{
#7
}
}
}
\clist_map_function:nN { #1 } \@@_map_aux:n
}
\@@_define_list_aux:nnnNNnn
{ new, renew, provide, declare }
{ theorem group } { theorem group }
{ #1 } { @@_use_group_##1: }
{ @@_use_group_#1: }
\@@_undefine_group_aux:n \@@_undefine_group_aux:n
\@@_define_group_aux:nnnnn \@@_define_group_aux:nnnnn
{ { groupthm_#1_group:nnnnn }
{ #1 } { #2 } { #3 } { #4 } { #5 } { { ##1 } { ##2 } { ##3 } { ##4 } { ##5 } }
}
}
% \end{macrocode} % \end{macrocode}
% %
% Finally, generate some extra variant. % Finally, generate some extra variant.
% %
% \begin{macrocode} % \begin{macrocode}
\cs_generate_variant:Nn \groupthm_new_theorem_group:nnnnn { n V V V V } \cs_generate_variant:Nn \groupthm_new_group:nnnnn { n V V V V }
% \end{macrocode} % \end{macrocode}
% \end{macro} % \end{macro}
% %
%
%
% \begin{macro}{\groupthm_renew_theorem_group:nnnnn, \groupthm_renew_theorem_group:nVVVV}
%
% \begin{macrocode} % \begin{macrocode}
\cs_new:Npn \groupthm_renew_theorem_group:nnnnn #1 #2 #3 #4 #5
{
\cs_if_exist:cTF { @@_use_group_#1: }
{
\@@_undefine_group_aux:n { #1 }
\@@_define_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 }
}
{
\msg_error:nnnnn { groupthm } { wrong ~ definition }
{ theorem ~ group } { #1 } { not }
}
}
% \end{macrocode} % \end{macrocode}
% %
% Finally, generate some extra variant.
%
% \begin{macrocode}
\cs_generate_variant:Nn \groupthm_renew_theorem_group:nnnnn { n V V V V }
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\groupthm_provide_theorem_group:nnnnn, \groupthm_provide_theorem_group:nVVVV}
%
% \begin{macrocode}
\cs_new:Npn \groupthm_provide_theorem_group:nnnnn #1 #2 #3 #4 #5
{
\cs_if_exist:cF { @@_use_group_#1: }
{
\@@_define_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 }
}
}
% \end{macrocode}
%
% Finally, generate some extra variant.
%
% \begin{macrocode}
\cs_generate_variant:Nn \groupthm_provide_theorem_group:nnnnn { n V V V V }
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\groupthm_declare_theorem_group:nnnnn, \groupthm_declare_theorem_group:nVVVV}
%
%
% \begin{macrocode}
\cs_new:Npn \groupthm_declare_theorem_group:nnnnn #1 #2 #3 #4 #5
{
\cs_if_exist:cT { @@_use_group_#1: }
{
\@@_undefine_group_aux:n { #1 }
}
\@@_define_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 }
}
% \end{macrocode}
%
% Finally, generate some extra variant.
%
% \begin{macrocode}
\cs_generate_variant:Nn \groupthm_declare_theorem_group:nnnnn { n V V V V }
% \end{macrocode}
% \end{macro}
% %
% %
% With the \cs{@@_set_normalized_keys:nnn} macro at hand, % With the \cs{@@_set_normalized_keys:nnn} macro at hand,
% it is also easy to provide key-value interfaces for these commands: % it is also easy to provide key-value interfaces for these commands:
% %
% \begin{macro}{\groupthm_new_theorem_group_from_keys:nn} % \begin{macro}{\groupthm_new_group_from_keys:nn}
% \begin{syntax} % \begin{syntax}
% \cs{groupthm_new_theorem_group_from_keys:nn}\marg{keys}\marg{theorem group} % \cs{groupthm_new_group_from_keys:nn}\marg{keys}\marg{theorem group}
% \end{syntax} % \end{syntax}
% %
% \begin{macrocode} % \begin{macrocode}
\cs_new:Npn \groupthm_new_theorem_group_from_keys:nn #1#2 \cs_new:Npn \groupthm_new_group_from_keys:nn #1#2
{ {
\@@_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 } \@@_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 }
\groupthm_new_theorem_group:nVVVV { #2 } \groupthm_new_group:nVVVV { #2 }
\l_@@_prefix_tl \l_@@_prefix_tl
\l_@@_suffix_tl \l_@@_suffix_tl
\l_@@_mapname_clist \l_@@_mapname_clist
@ -1660,16 +1612,16 @@
% %
% %
% %
% \begin{macro}{\groupthm_renew_theorem_group_from_keys:nn} % \begin{macro}{\groupthm_renew_group_from_keys:nn}
% \begin{syntax} % \begin{syntax}
% \cs{groupthm_renew_theorem_group_from_keys:nn}\marg{keys}\marg{theorem group} % \cs{groupthm_renew_group_from_keys:nn}\marg{keys}\marg{theorem group}
% \end{syntax} % \end{syntax}
% %
% \begin{macrocode} % \begin{macrocode}
\cs_new:Npn \groupthm_renew_theorem_group_from_keys:nn #1#2 \cs_new:Npn \groupthm_renew_group_from_keys:nn #1#2
{ {
\@@_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 } \@@_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 }
\groupthm_renew_theorem_group:nVVVV { #2 } \groupthm_renew_group:nVVVV { #2 }
\l_@@_prefix_tl \l_@@_prefix_tl
\l_@@_suffix_tl \l_@@_suffix_tl
\l_@@_mapname_clist \l_@@_mapname_clist
@ -1727,7 +1679,7 @@
% \begin{macrocode} % \begin{macrocode}
\NewDocumentCommand{\NewTheoremGroup}{ O{} m } \NewDocumentCommand{\NewTheoremGroup}{ O{} m }
{ {
\groupthm_new_theorem_group_from_keys:nn { #1 } { #2 } \groupthm_new_group_from_keys:nn { #1 } { #2 }
} }
% \end{macrocode} % \end{macrocode}
% \end{macro} % \end{macro}
@ -1739,7 +1691,7 @@
% \begin{macrocode} % \begin{macrocode}
\NewDocumentCommand{\RenewTheoremGroup}{ O{} m } \NewDocumentCommand{\RenewTheoremGroup}{ O{} m }
{ {
\groupthm_renew_theorem_group_from_keys:nn { #1 } { #2 } \groupthm_renew_group_from_keys:nn { #1 } { #2 }
} }
% \end{macrocode} % \end{macrocode}
% \end{macro} % \end{macro}

View file

@ -260,63 +260,50 @@
} }
\cs_generate_variant:Nn \__groupthm_define_aux:nnnNNNn { n n n c N N n } \cs_generate_variant:Nn \__groupthm_define_aux:nnnNNNn { n n n c N N n }
\cs_new:Npn \groupthm_new_theorem_group:nnnnn #1 #2 #3 #4 #5 \cs_new:Npn \__groupthm_define_list_aux:nnnNNnn #1 #2 #3 #4 #5 #6 #7
{ {
\cs_set:Npn \__groupthm_map_aux:n ##1
{
\cs_new:cn { #6 }
{
\__groupthm_define_aux:nnncNNn \__groupthm_define_aux:nnncNNn
{ new } { ##1 }
{ #2 }
{ ####1 }
{ #3 }
#4
#5
{
#7
}
}
}
\clist_map_function:nN { #1 } \__groupthm_map_aux:n
}
\__groupthm_define_list_aux:nnnNNnn
{ new, renew, provide, declare }
{ theorem group } { theorem group }
{ #1 } { __groupthm_use_group_##1: }
{ __groupthm_use_group_#1: }
\__groupthm_undefine_group_aux:n \__groupthm_undefine_group_aux:n
\__groupthm_define_group_aux:nnnnn \__groupthm_define_group_aux:nnnnn
{ { groupthm_#1_group:nnnnn }
{ #1 } { #2 } { #3 } { #4 } { #5 } { { ##1 } { ##2 } { ##3 } { ##4 } { ##5 } }
} \cs_generate_variant:Nn \groupthm_new_group:nnnnn { n V V V V }
}
\cs_generate_variant:Nn \groupthm_new_theorem_group:nnnnn { n V V V V } \cs_new:Npn \groupthm_new_group_from_keys:nn #1#2
\cs_new:Npn \groupthm_renew_theorem_group:nnnnn #1 #2 #3 #4 #5
{
\cs_if_exist:cTF { __groupthm_use_group_#1: }
{
\__groupthm_undefine_group_aux:n { #1 }
\__groupthm_define_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 }
}
{
\msg_error:nnnnn { groupthm } { wrong ~ definition }
{ theorem ~ group } { #1 } { not }
}
}
\cs_generate_variant:Nn \groupthm_renew_theorem_group:nnnnn { n V V V V }
\cs_new:Npn \groupthm_provide_theorem_group:nnnnn #1 #2 #3 #4 #5
{
\cs_if_exist:cF { __groupthm_use_group_#1: }
{
\__groupthm_define_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 }
}
}
\cs_generate_variant:Nn \groupthm_provide_theorem_group:nnnnn { n V V V V }
\cs_new:Npn \groupthm_declare_theorem_group:nnnnn #1 #2 #3 #4 #5
{
\cs_if_exist:cT { __groupthm_use_group_#1: }
{
\__groupthm_undefine_group_aux:n { #1 }
}
\__groupthm_define_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 }
}
\cs_generate_variant:Nn \groupthm_declare_theorem_group:nnnnn { n V V V V }
\cs_new:Npn \groupthm_new_theorem_group_from_keys:nn #1#2
{ {
\__groupthm_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 } \__groupthm_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 }
\groupthm_new_theorem_group:nVVVV { #2 } \groupthm_new_group:nVVVV { #2 }
\l__groupthm_prefix_tl \l__groupthm_prefix_tl
\l__groupthm_suffix_tl \l__groupthm_suffix_tl
\l__groupthm_mapname_clist \l__groupthm_mapname_clist
\l__groupthm_thmtools_clist \l__groupthm_thmtools_clist
} }
\cs_new:Npn \groupthm_renew_theorem_group_from_keys:nn #1#2 \cs_new:Npn \groupthm_renew_group_from_keys:nn #1#2
{ {
\__groupthm_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 } \__groupthm_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 }
\groupthm_renew_theorem_group:nVVVV { #2 } \groupthm_renew_group:nVVVV { #2 }
\l__groupthm_prefix_tl \l__groupthm_prefix_tl
\l__groupthm_suffix_tl \l__groupthm_suffix_tl
\l__groupthm_mapname_clist \l__groupthm_mapname_clist
@ -342,11 +329,11 @@
} }
\NewDocumentCommand{\NewTheoremGroup}{ O{} m } \NewDocumentCommand{\NewTheoremGroup}{ O{} m }
{ {
\groupthm_new_theorem_group_from_keys:nn { #1 } { #2 } \groupthm_new_group_from_keys:nn { #1 } { #2 }
} }
\NewDocumentCommand{\RenewTheoremGroup}{ O{} m } \NewDocumentCommand{\RenewTheoremGroup}{ O{} m }
{ {
\groupthm_renew_theorem_group_from_keys:nn { #1 } { #2 } \groupthm_renew_group_from_keys:nn { #1 } { #2 }
} }
\NewDocumentCommand{\ProvideTheoremGroup}{ O{} m } \NewDocumentCommand{\ProvideTheoremGroup}{ O{} m }
{ {