add theorem family options, improve error messages

This commit is contained in:
Maximilian Keßler 2022-01-18 21:14:02 +01:00
parent 61f955c4aa
commit a9e98e25d9
3 changed files with 569 additions and 183 deletions

View file

@ -1026,9 +1026,9 @@
%
% When the special \cs{AddTheoremToGroup} macro is issued outside a theorem family options
% body.
\begin{syntax}
\cs{msg_error:nn} \{ groupthm \}\{ misuse add theorem to group \}
\end{syntax}
% \begin{syntax}
% \cs{msg_error:nn} \{ groupthm \}\{ misuse add theorem to group \}
% \end{syntax}
% \begin{macrocode}
\msg_new:nnn { groupthm } { misuse ~ add ~ theorem ~ to ~ group }
{
@ -1036,6 +1036,26 @@
family ~ options ~ \msg_line_context:
}
% \end{macrocode}
%
%
%
% When a theorem family is invoked, but has not been generated yet.
% \begin{syntax}
% \cs{msg_error:nn} \{ groupthm \}\{ undefined theorem variant \}
% \end{syntax}
% \begin{macrocode}
\msg_new:nnnn { groupthm } { undefined ~ theorem ~ variant }
{
Bad ~ call ~ of ~ theorem ~ variant ~ of ~ '#1' ~ \msg_line_context:
}
{
You ~ wanted ~ to ~ call ~ the ~ variant ~ with ~ group(s) ~
'#2' ~ of ~ theorem ~ family ~ '#1', ~ but ~ it ~ has ~ not ~ been ~
generated ~ yet. ~
Probably ~ you ~ forgot ~ this. ~
\msg_see_documentation_text:n { groupthm }
}
% \end{macrocode}
%
% \subsection{Allocation and initialization}
%
@ -1118,7 +1138,7 @@
% \end{macrocode}
% \end{variable}
%
\begin{variable}{\l_@@_in_family_options_environment_bool}
% \begin{variable}{\l_@@_in_family_options_environment_bool}
% This variable indicates whether we are in the special environment
% used to parse a set of groups out of options given to a theorem
% family.
@ -1127,7 +1147,7 @@
% \begin{macrocode}
\bool_new:N \l_@@_in_family_options_environment_bool
% \end{macrocode}
\end{variable}
% \end{variable}
%
%
% \subsection{Key interface}
@ -2850,6 +2870,23 @@
% \end{macro}
%
%
% \begin{macro}{\AddTheoremToGroup}
% \begin{syntax}
% \cs{AddTheoremToGroup}\marg{theorem group}
% \end{syntax}
%
%
%
% \begin{macrocode}
\NewDocumentCommand { \AddTheoremToGroup } { m }
{
\groupthm_add_theorem_to_group:n { #1 }
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\@@_declare_theorem_family_options_aux:nnnnn}
% \begin{syntax}
% \c{@@_declare_theorem_family_options_aux:nnnnn}\marg{theorem family}
@ -2866,7 +2903,7 @@
% and \texttt{Declare} and is given to the \texttt{DocumentEnvironment} command from \pkg{xpars}.
%
% \begin{macrocode}
\cs_new:Npn \__declare_theorem_family_options_aux:nnnnnn #1 #2 #3 #4 #5 #6
\cs_new:Npn \@@_declare_theorem_family_options_aux:nnnnn #1 #2 #3 #4 #5
{
\use:c{ #5 DocumentEnvironment }
{ #1 }
@ -2875,30 +2912,43 @@
% \end{macrocode}
% We can now clear the group list and execute the \meta{selection body}
% that populates this list again.
% Additionally, we add the groups that should always be present.
% Additionally, we add the groups that should always be present and activate the
% \cs{AddTheoremToGroup} macro by setting the bool.
% \begin{macrocode}
\clist_clear:N \l_@@_group_clist
\bool_set_true:N \l_@@_in_family_options_environment_bool
#3
\clist_put_right:NV \l_@@_group_clist { #4 }
\bool_set_false:N \l_@@_in_family_options_environment_bool
\clist_put_right:Nn \l_@@_group_clist { #4 }
% \end{macrocode}
% We now got the list of groups parsed. We sort this and start the corresponding
% environment that has been generated by a \cs{NewGroupedTheoremFamily} command
% or similar.
% \begin{macrocode}
\__sort_group_names:
\begin { __#1__groups_ \clist_use:Nn \l_@@_group_clist { _ } }
\@@_sort_theorem_group_names:
\cs_if_exist:cTF { __#1__groups_ \clist_use:Nn \l_@@_group_clist { _ } }
{
\begin { __#1__groups_ \clist_use:Nn \l_@@_group_clist { _ } }
}
{
\msg_error:nnxx { groupthm } { undefined ~ theorem ~ variant }
{ #1 }
{ \clist_use:Nnnn \l_@@_group_clist { ~ and ~ } {, ~} { , ~ and ~ } }
}
}
{
% \end{macrocode}
% At the end of the environment, we have to do the same parsing again.
% \begin{macrocode}
\clist_clear:N \l_@@_group_clist
\bool_set_true:N \l_@@_in_family_options_environment_bool
#3
\clist_put_right:NV \l_@@_group_clist { #4 }
\bool_set_false:N \l_@@_in_family_options_environment_bool
\clist_put_right:Nn \l_@@_group_clist { #4 }
% \end{macrocode}
% End the corresponding environment.
% \begin{macrocode}
\__sort_group_names:
\@@_sort_theorem_group_names:
\end { __#1__groups_ \clist_use:Nn \l_@@_group_clist { _ } }
}
}
@ -2909,136 +2959,68 @@
% All other macros are now essentially wrappers around this aux macro,
% passing different \meta{extra groups} to them
%
% \begin{macro}{\groupthm_new_grouped_theorem_family_options:nnnn}
% \begin{macro}{\groupthm_new_grouped_theorem_family_options:nnn}
% \begin{syntax}
% \cs{groupthm_new_grouped_theorem_family_options:nnnn}\marg{theorem family}
% \cs{groupthm_new_grouped_theorem_family_options:nnn}\marg{theorem family}
% \marg{signature}\marg{selection body}
% \end{syntax}
%
% \begin{macrocode}
\cs_new:Npn \groupthm_new_grouped_theorem_family_options:nnnn #1 #2 #3 #4
\cs_new:Npn \groupthm_new_grouped_theorem_family_options:nnn #1 #2 #3
{
\@@_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { } { New }
\@@_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { New }
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\groupthm_renew_grouped_theorem_family_options:nnnn}
% \begin{macro}{\groupthm_renew_grouped_theorem_family_options:nnn}
% \begin{syntax}
% \cs{groupthm_renew_grouped_theorem_family_options:nnnn}\marg{theorem family}
% \cs{groupthm_renew_grouped_theorem_family_options:nnn}\marg{theorem family}
% \marg{signature}\marg{selection body}
% \end{syntax}
%
% \begin{macrocode}
\cs_new:Npn \groupthm_renew_grouped_theorem_family_options:nnnn #1 #2 #3 #4
\cs_new:Npn \groupthm_renew_grouped_theorem_family_options:nnn #1 #2 #3
{
\@@_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { } { Renew }
\@@_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Renew }
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\groupthm_provide_grouped_theorem_family_options:nnnn}
% \begin{macro}{\groupthm_provide_grouped_theorem_family_options:nnn}
% \begin{syntax}
% \cs{groupthm_provide_grouped_theorem_family_options:nnnn}\marg{theorem family}
% \cs{groupthm_provide_grouped_theorem_family_options:nnn}\marg{theorem family}
% \marg{signature}\marg{selection body}
% \end{syntax}
%
% \begin{macrocode}
\cs_new:Npn \groupthm_provide_grouped_theorem_family_options:nnnn #1 #2 #3 #4
\cs_new:Npn \groupthm_provide_grouped_theorem_family_options:nnn #1 #2 #3
{
\@@_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { } { Provide }
\@@_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Provide }
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\groupthm_declare_grouped_theorem_family_options:nnnn}
% \begin{macro}{\groupthm_declare_grouped_theorem_family_options:nnn}
% \begin{syntax}
% \cs{groupthm_declare_grouped_theorem_family_options:nnnn}\marg{theorem family}
% \cs{groupthm_declare_grouped_theorem_family_options:nnn}\marg{theorem family}
% \marg{signature}\marg{selection body}
% \end{syntax}
%
% \begin{macrocode}
\cs_new:Npn \groupthm_declare_grouped_theorem_family_options:nnnn #1 #2 #3 #4
\cs_new:Npn \groupthm_declare_grouped_theorem_family_options:nnn #1 #2 #3
{
\@@_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { } { Declare }
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\groupthm_new_grouped_theorem_family_options_star:nnnn}
% \begin{syntax}
% \cs{groupthm_new_grouped_theorem_family_options_star:nnnn}\marg{theorem family}
% \marg{signature}\marg{selection body}
% \end{syntax}
%
% \begin{macrocode}
\cs_new:Npn \groupthm_new_grouped_theorem_family_options_star:nnnn #1 #2 #3 #4
{
\@@_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { unnumbered } { New }
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\groupthm_renew_grouped_theorem_family_options_star:nnnn}
% \begin{syntax}
% \cs{groupthm_renew_grouped_theorem_family_options_star:nnnn}\marg{theorem family}
% \marg{signature}\marg{selection body}
% \end{syntax}
%
% \begin{macrocode}
\cs_new:Npn \groupthm_renew_grouped_theorem_family_options_star:nnnn #1 #2 #3 #4
{
\@@_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { unnumbered } { Renew }
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\groupthm_provide_grouped_theorem_family_options_star:nnnn}
% \begin{syntax}
% \cs{groupthm_provide_grouped_theorem_family_options_star:nnnn}\marg{theorem family}
% \marg{signature}\marg{selection body}
% \end{syntax}
%
% \begin{macrocode}
\cs_new:Npn \groupthm_provide_grouped_theorem_family_options_star:nnnn #1 #2 #3 #4
{
\@@_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { unnumbered } { Provide }
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\groupthm_declare_grouped_theorem_family_options_star:nnnn}
% \begin{syntax}
% \cs{groupthm_declare_grouped_theorem_family_options_star:nnnn}\marg{theorem family}
% \marg{signature}\marg{selection body}
% \end{syntax}
%
% \begin{macrocode}
\cs_new:Npn \groupthm_declare_grouped_theorem_family_options_star:nnnn #1 #2 #3 #4
{
\@@_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { unnumbered } { Declare }
\@@_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Declare }
}
% \end{macrocode}
% \end{macro}
@ -3048,74 +3030,74 @@
% The variants without \enquote{grouped} in their name will just issue two commands,
% one with and one without the \texttt{starred} group, and add a \enquote{*} to the name.
%
% \begin{macro}{\groupthm_new_theorem_family_options:nnnn}
% \begin{macro}{\groupthm_new_theorem_family_options:nnn}
% \begin{syntax}
% \cs{groupthm_new_theorem_family_options:nnnn}\marg{theorem family}
% \cs{groupthm_new_theorem_family_options:nnn}\marg{theorem family}
% \marg{signature}\marg{selection body}
% \end{syntax}
%
%
% \begin{macrocode}
\cs_new:Npn \groupthm_new_theorem_family_options:nnnn #1 #2 #3 #4
\cs_new:Npn \groupthm_new_theorem_family_options:nnn #1 #2 #3
{
\@@_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { } { New }
\@@_declare_theorem_family_options_aux:nnnnnn
{ #1* } { #2 } { #3 } { #4 } { starred } { New }
\@@_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { New }
\@@_declare_theorem_family_options_aux:nnnnn
{ #1* } { #2 } { #3 } { starred } { New }
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\groupthm_renew_theorem_family_options:nnnn}
% \begin{macro}{\groupthm_renew_theorem_family_options:nnn}
% \begin{syntax}
% \cs{groupthm_renew_theorem_family_options:nnnn}\marg{theorem family}
% \cs{groupthm_renew_theorem_family_options:nnn}\marg{theorem family}
% \marg{signature}\marg{selection body}
% \end{syntax}
%
%
% \begin{macrocode}
\cs_new:Npn \groupthm_renew_theorem_family_options:nnnn #1 #2 #3 #4
\cs_new:Npn \groupthm_renew_theorem_family_options:nnn #1 #2 #3
{
\@@_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { } { Renew }
\@@_declare_theorem_family_options_aux:nnnnnn
{ #1* } { #2 } { #3 } { #4 } { starred } { Renew }
\@@_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Renew }
\@@_declare_theorem_family_options_aux:nnnnn
{ #1* } { #2 } { #3 } { starred } { Renew }
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\groupthm_provide_theorem_family_options:nnnn}
% \begin{macro}{\groupthm_provide_theorem_family_options:nnn}
% \begin{syntax}
% \cs{groupthm_provide_theorem_family_options:nnnn}\marg{theorem family}
% \cs{groupthm_provide_theorem_family_options:nnn}\marg{theorem family}
% \marg{signature}\marg{selection body}
% \end{syntax}
%
%
% \begin{macrocode}
\cs_new:Npn \groupthm_provide_theorem_family_options:nnnn #1 #2 #3 #4
\cs_new:Npn \groupthm_provide_theorem_family_options:nnn #1 #2 #3
{
\@@_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { } { Provide }
\@@_declare_theorem_family_options_aux:nnnnnn
{ #1* } { #2 } { #3 } { #4 } { starred } { Provide }
\@@_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Provide }
\@@_declare_theorem_family_options_aux:nnnnn
{ #1* } { #2 } { #3 } { starred } { Provide }
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\groupthm_declare_theorem_family_options:nnnn}
% \begin{macro}{\groupthm_declare_theorem_family_options:nnn}
% \begin{syntax}
% \cs{groupthm_declare_theorem_family_options:nnnn}\marg{theorem family}
% \cs{groupthm_declare_theorem_family_options:nnn}\marg{theorem family}
% \marg{signature}\marg{selection body}
% \end{syntax}
%
%
% \begin{macrocode}
\cs_new:Npn \groupthm_declare_theorem_family_options:nnnn #1 #2 #3 #4
\cs_new:Npn \groupthm_declare_theorem_family_options:nnn #1 #2 #3
{
\@@_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { } { Declare }
\@@_declare_theorem_family_options_aux:nnnnnn
{ #1* } { #2 } { #3 } { #4 } { starred } { Declare }
\@@_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Declare }
\@@_declare_theorem_family_options_aux:nnnnn
{ #1* } { #2 } { #3 } { starred } { Declare }
}
% \end{macrocode}
% \end{macro}
@ -3123,6 +3105,250 @@
%
% It remains to wrap these into document commands
%
%
% \begin{macro}{\NewGroupedTheoremFamilyOptions, \NewGroupedTheoremFamilyOptions*}
% \begin{syntax}
% \cs{NewGroupedTheoremFamilyOptions}\marg{family name}\marg{signature}
% \marg{selection body}
% \end{syntax}
%
% \begin{macrocode}
\NewDocumentCommand { \NewGroupedTheoremFamilyOptions } { s m m m }
{
\IfBooleanTF { #1 }
{
\groupthm_new_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_new_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\RenewGroupedTheoremFamilyOptions, \RenewGroupedTheoremFamilyOptions*}
% \begin{syntax}
% \cs{RenewGroupedTheoremFamilyOptions}\marg{family name}\marg{signature}
% \marg{selection body}
% \end{syntax}
%
% \begin{macrocode}
\NewDocumentCommand { \RenewGroupedTheoremFamilyOptions } { s m m m }
{
\IfBooleanTF { #1 }
{
\groupthm_renew_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_renew_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\ProvideGroupedTheoremFamilyOptions, \ProvideGroupedTheoremFamilyOptions*}
% \begin{syntax}
% \cs{ProvideGroupedTheoremFamilyOptions}\marg{family name}\marg{signature}
% \marg{selection body}
% \end{syntax}
%
% \begin{macrocode}
\NewDocumentCommand { \ProvideGroupedTheoremFamilyOptions } { s m m m }
{
\IfBooleanTF { #1 }
{
\groupthm_provide_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_provide_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\DeclareGroupedTheoremFamilyOptions, \DeclareGroupedTheoremFamilyOptions*}
% \begin{syntax}
% \cs{DeclareGroupedTheoremFamilyOptions}\marg{family name}\marg{signature}
% \marg{selection body}
% \end{syntax}
%
% \begin{macrocode}
\NewDocumentCommand { \DeclareGroupedTheoremFamilyOptions } { s m m m }
{
\IfBooleanTF { #1 }
{
\groupthm_declare_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_declare_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
% \end{macrocode}
% \end{macro}
%
%
%
%
%
% \begin{macro}{\NewTheoremFamilyOptions, \NewTheoremFamilyOptions*}
% \begin{syntax}
% \cs{NewTheoremFamilyOptions}\marg{family name}\marg{signature}
% \marg{selection body}
% \end{syntax}
%
% \begin{macrocode}
\NewDocumentCommand { \NewTheoremFamilyOptions } { s m m m }
{
\IfBooleanTF { #1 }
{
\groupthm_new_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_new_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\RenewTheoremFamilyOptions, \RenewTheoremFamilyOptions*}
% \begin{syntax}
% \cs{RenewTheoremFamilyOptions}\marg{family name}\marg{signature}
% \marg{selection body}
% \end{syntax}
%
% \begin{macrocode}
\NewDocumentCommand { \RenewTheoremFamilyOptions } { s m m m }
{
\IfBooleanTF { #1 }
{
\groupthm_renew_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_renew_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\ProvideTheoremFamilyOptions, \ProvideTheoremFamilyOptions*}
% \begin{syntax}
% \cs{ProvideTheoremFamilyOptions}\marg{family name}\marg{signature}
% \marg{selection body}
% \end{syntax}
%
% \begin{macrocode}
\NewDocumentCommand { \ProvideTheoremFamilyOptions } { s m m m }
{
\IfBooleanTF { #1 }
{
\groupthm_provide_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_provide_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\DeclareTheoremFamilyOptions, \DeclareTheoremFamilyOptions*}
% \begin{syntax}
% \cs{DeclareTheoremFamilyOptions}\marg{family name}\marg{signature}
% \marg{selection body}
% \end{syntax}
%
% \begin{macrocode}
\NewDocumentCommand { \DeclareTheoremFamilyOptions } { s m m m }
{
\IfBooleanTF { #1 }
{
\groupthm_declare_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_declare_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
% \end{macrocode}
% \end{macro}
%
%
%
@ -3134,5 +3360,11 @@
% \end{macrocode}
%
% \end{implementation}
%
%
%
%
%
%
% \newpage
% \PrintIndex

View file

@ -50,14 +50,22 @@
{
Bad ~ definition ~ of ~ #1 ~ '#2' ~ \msg_line_context:, ~ #1 ~ is ~ #3 ~ defined.
}
\begin{syntax}
\cs{msg_error:nn} \{ groupthm \}\{ misuse add theorem to group \}
\end{syntax}
\msg_new:nnn { groupthm } { misuse ~ add ~ theorem ~ to ~ group }
{
Bad ~ usage ~ of ~ 'AddTheoremToGroup' ~ macro ~ outside ~ theorem ~
family ~ options ~ \msg_line_context:
}
\msg_new:nnnn { groupthm } { undefined ~ theorem ~ variant }
{
Bad ~ call ~ of ~ theorem ~ variant ~ of ~ '#1' ~ \msg_line_context:
}
{
You ~ wanted ~ to ~ call ~ the ~ variant ~ with ~ group(s) ~
'#2' ~ of ~ theorem ~ family ~ '#1', ~ but ~ it ~ has ~ not ~ been ~
generated ~ yet. ~
Probably ~ you ~ forgot ~ this. ~
\msg_see_documentation_text:n { groupthm }
}
\hook_new:n { __groupthm/prename }
\hook_new:n { __groupthm/postname }
\hook_new:n { __groupthm/mapname }
@ -77,9 +85,7 @@
\clist_new:N \l__groupthm_thmtools_clist
\clist_new:N \l__groupthm_group_clist
\clist_new:N \g__groupthm_defined_theorem_groups_clist
\begin{variable}{\l__groupthm_in_family_options_environment_bool}
\bool_new:N \l__groupthm_in_family_options_environment_bool
\end{variable}
\keys_define:nn { groupthm }
{
prename .tl_set:N = \l__groupthm_key_prename_tl,
@ -777,93 +783,241 @@
\msg_error:nn { groupthm } { misuse ~ add ~ theorem ~ to ~ group }
}
}
\cs_new:Npn \__declare_theorem_family_options_aux:nnnnnn #1 #2 #3 #4 #5 #6
\NewDocumentCommand { \AddTheoremToGroup } { m }
{
\groupthm_add_theorem_to_group:n { #1 }
}
\cs_new:Npn \__groupthm_declare_theorem_family_options_aux:nnnnn #1 #2 #3 #4 #5
{
\use:c{ #5 DocumentEnvironment }
{ #1 }
{ #2 }
{
\clist_clear:N \l__groupthm_group_clist
\bool_set_true:N \l__groupthm_in_family_options_environment_bool
#3
\clist_put_right:NV \l__groupthm_group_clist { #4 }
\__sort_group_names:
\begin { __#1__groups_ \clist_use:Nn \l__groupthm_group_clist { _ } }
\bool_set_false:N \l__groupthm_in_family_options_environment_bool
\clist_put_right:Nn \l__groupthm_group_clist { #4 }
\__groupthm_sort_theorem_group_names:
\cs_if_exist:cTF { __#1__groups_ \clist_use:Nn \l__groupthm_group_clist { _ } }
{
\begin { __#1__groups_ \clist_use:Nn \l__groupthm_group_clist { _ } }
}
{
\msg_error:nnxx { groupthm } { undefined ~ theorem ~ variant }
{ #1 }
{ \clist_use:Nnnn \l__groupthm_group_clist { ~ and ~ } {, ~} { , ~ and ~ } }
}
}
{
\clist_clear:N \l__groupthm_group_clist
\bool_set_true:N \l__groupthm_in_family_options_environment_bool
#3
\clist_put_right:NV \l__groupthm_group_clist { #4 }
\__sort_group_names:
\bool_set_false:N \l__groupthm_in_family_options_environment_bool
\clist_put_right:Nn \l__groupthm_group_clist { #4 }
\__groupthm_sort_theorem_group_names:
\end { __#1__groups_ \clist_use:Nn \l__groupthm_group_clist { _ } }
}
}
\cs_new:Npn \groupthm_new_grouped_theorem_family_options:nnnn #1 #2 #3 #4
\cs_new:Npn \groupthm_new_grouped_theorem_family_options:nnn #1 #2 #3
{
\__groupthm_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { } { New }
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { New }
}
\cs_new:Npn \groupthm_renew_grouped_theorem_family_options:nnnn #1 #2 #3 #4
\cs_new:Npn \groupthm_renew_grouped_theorem_family_options:nnn #1 #2 #3
{
\__groupthm_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { } { Renew }
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Renew }
}
\cs_new:Npn \groupthm_provide_grouped_theorem_family_options:nnnn #1 #2 #3 #4
\cs_new:Npn \groupthm_provide_grouped_theorem_family_options:nnn #1 #2 #3
{
\__groupthm_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { } { Provide }
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Provide }
}
\cs_new:Npn \groupthm_declare_grouped_theorem_family_options:nnnn #1 #2 #3 #4
\cs_new:Npn \groupthm_declare_grouped_theorem_family_options:nnn #1 #2 #3
{
\__groupthm_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { } { Declare }
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Declare }
}
\cs_new:Npn \groupthm_new_grouped_theorem_family_options_star:nnnn #1 #2 #3 #4
\cs_new:Npn \groupthm_new_theorem_family_options:nnn #1 #2 #3
{
\__groupthm_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { unnumbered } { New }
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { New }
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1* } { #2 } { #3 } { starred } { New }
}
\cs_new:Npn \groupthm_renew_grouped_theorem_family_options_star:nnnn #1 #2 #3 #4
\cs_new:Npn \groupthm_renew_theorem_family_options:nnn #1 #2 #3
{
\__groupthm_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { unnumbered } { Renew }
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Renew }
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1* } { #2 } { #3 } { starred } { Renew }
}
\cs_new:Npn \groupthm_provide_grouped_theorem_family_options_star:nnnn #1 #2 #3 #4
\cs_new:Npn \groupthm_provide_theorem_family_options:nnn #1 #2 #3
{
\__groupthm_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { unnumbered } { Provide }
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Provide }
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1* } { #2 } { #3 } { starred } { Provide }
}
\cs_new:Npn \groupthm_declare_grouped_theorem_family_options_star:nnnn #1 #2 #3 #4
\cs_new:Npn \groupthm_declare_theorem_family_options:nnn #1 #2 #3
{
\__groupthm_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { unnumbered } { Declare }
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Declare }
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1* } { #2 } { #3 } { starred } { Declare }
}
\cs_new:Npn \groupthm_new_theorem_family_options:nnnn #1 #2 #3 #4
\NewDocumentCommand { \NewGroupedTheoremFamilyOptions } { s m m m }
{
\__groupthm_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { } { New }
\__groupthm_declare_theorem_family_options_aux:nnnnnn
{ #1* } { #2 } { #3 } { #4 } { starred } { New }
\IfBooleanTF { #1 }
{
\groupthm_new_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_new_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
\cs_new:Npn \groupthm_renew_theorem_family_options:nnnn #1 #2 #3 #4
\NewDocumentCommand { \RenewGroupedTheoremFamilyOptions } { s m m m }
{
\__groupthm_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { } { Renew }
\__groupthm_declare_theorem_family_options_aux:nnnnnn
{ #1* } { #2 } { #3 } { #4 } { starred } { Renew }
\IfBooleanTF { #1 }
{
\groupthm_renew_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_renew_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
\cs_new:Npn \groupthm_provide_theorem_family_options:nnnn #1 #2 #3 #4
\NewDocumentCommand { \ProvideGroupedTheoremFamilyOptions } { s m m m }
{
\__groupthm_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { } { Provide }
\__groupthm_declare_theorem_family_options_aux:nnnnnn
{ #1* } { #2 } { #3 } { #4 } { starred } { Provide }
\IfBooleanTF { #1 }
{
\groupthm_provide_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_provide_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
\cs_new:Npn \groupthm_declare_theorem_family_options:nnnn #1 #2 #3 #4
\NewDocumentCommand { \DeclareGroupedTheoremFamilyOptions } { s m m m }
{
\__groupthm_declare_theorem_family_options_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { } { Declare }
\__groupthm_declare_theorem_family_options_aux:nnnnnn
{ #1* } { #2 } { #3 } { #4 } { starred } { Declare }
\IfBooleanTF { #1 }
{
\groupthm_declare_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_declare_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
\NewDocumentCommand { \NewTheoremFamilyOptions } { s m m m }
{
\IfBooleanTF { #1 }
{
\groupthm_new_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_new_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
\NewDocumentCommand { \RenewTheoremFamilyOptions } { s m m m }
{
\IfBooleanTF { #1 }
{
\groupthm_renew_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_renew_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
\NewDocumentCommand { \ProvideTheoremFamilyOptions } { s m m m }
{
\IfBooleanTF { #1 }
{
\groupthm_provide_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_provide_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
\NewDocumentCommand { \DeclareTheoremFamilyOptions } { s m m m }
{
\IfBooleanTF { #1 }
{
\groupthm_declare_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_declare_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
\endinput
%%