implement options in document level

This commit is contained in:
Maximilian Keßler 2022-01-22 17:46:32 +01:00
parent cc853a87e2
commit 7ab693a7cb
2 changed files with 118 additions and 570 deletions

View file

@ -1223,6 +1223,13 @@
unknown .code:n =
\msg_error:nnn { groupthm } { unknown ~ key } { \l_keys_key_str }
}
\keys_define:nn { groupthm / theorem ~ family ~ options }
{
starred ~ version .bool_set:N = \l_@@_key_starred_version_bool,
starred ~ version .default:n = { true },
unknown .code:n =
\msg_error:nnn { groupthm } { unknown ~ key } { \l_keys_key_str }
}
% \end{macrocode}
%
%
@ -1621,7 +1628,12 @@
% Finally, define new version if not already defined
% (this check is necessary for the provide version.)
% \begin{macrocode}
\cs_if_exist:NTF #4
\bool_if:nTF
{
\cs_if_exist_p:N #4
&&
\str_if_eq_p:nn { #1 } { provide }
}
{
\tl_log:n { Providing ~ #2 ~ '#3' ~ skipped: ~ '#3' ~ already ~ defined. }
}
@ -2457,10 +2469,10 @@
%
%
%
% \begin{macro}{\@@_declare_theorem_family_options_aux:nnnnn}
% \begin{macro}{\@@_define_family_options::nnnn}
% \begin{syntax}
% \c{@@_declare_theorem_family_options_aux:nnnnn}\marg{theorem family}
% \marg{argument specification}\marg{selection body}\marg{extra groups}\marg{declaring backend}
% \cs{@@_define_family_options::nnnn}\marg{theorem family}
% \marg{argument specification}\marg{selection body}\marg{extra groups}
% \end{syntax}
%
% This declares a new theorem variant option parser, i.e.~ introduces the environment
@ -2473,9 +2485,9 @@
% and \texttt{Declare} and is given to the \texttt{DocumentEnvironment} command from \pkg{xpars}.
%
% \begin{macrocode}
\cs_new:Npn \@@_declare_theorem_family_options_aux:nnnnn #1 #2 #3 #4 #5
\cs_new:Npn \@@_define_family_options:nnnn #1 #2 #3 #4
{
\use:c{ #5 DocumentEnvironment }
\DeclareDocumentEnvironment
{ #1 }
{ #2 }
{
@ -2529,146 +2541,31 @@
% All other macros are now essentially wrappers around this aux macro,
% passing different \mymeta{extra groups} to them
%
% \begin{macro}{\groupthm_new_grouped_theorem_family_options:nnn}
% \begin{macro}
% {
% \groupthm_new_family_options:nnnn,
% \groupthm_renew_family_options:nnnn,
% \groupthm_provide_family_options:nnnn,
% \groupthm_declare_family_options:nnnn,
% }
% \begin{syntax}
% \cs{groupthm_new_grouped_theorem_family_options:nnn}\marg{theorem family}
% \marg{signature}\marg{selection body}
% \cs{groupthm_new_family_options:nnnn}\marg{theorem family}
% \marg{signature}\marg{selection body}\marg{groups}
% \end{syntax}
%
% \begin{macrocode}
\cs_new:Npn \groupthm_new_grouped_theorem_family_options:nnn #1 #2 #3
{
\@@_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { New }
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\groupthm_renew_grouped_theorem_family_options:nnn}
% \begin{syntax}
% \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:nnn #1 #2 #3
{
\@@_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Renew }
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\groupthm_provide_grouped_theorem_family_options:nnn}
% \begin{syntax}
% \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:nnn #1 #2 #3
{
\@@_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Provide }
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\groupthm_declare_grouped_theorem_family_options:nnn}
% \begin{syntax}
% \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:nnn #1 #2 #3
{
\@@_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Declare }
}
% \end{macrocode}
% \end{macro}
%
%
%
% 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:nnn}
% \begin{syntax}
% \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:nnn #1 #2 #3
{
\@@_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:nnn}
% \begin{syntax}
% \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:nnn #1 #2 #3
{
\@@_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:nnn}
% \begin{syntax}
% \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:nnn #1 #2 #3
{
\@@_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:nnn}
% \begin{syntax}
% \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:nnn #1 #2 #3
{
\@@_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Declare }
\@@_declare_theorem_family_options_aux:nnnnn
{ #1* } { #2 } { #3 } { starred } { Declare }
}
\@@_define_multiple:nnnNNnn
{ new, renew, provide, declare }
{ theorem ~ family ~ options }
{ ##1 }
\use_none:n
\@@_define_family_options:nnnn
{ groupthm_#1_family_options:nnnn }
{ { ##1 } { ##2 } { ##3 } { ##4 } }
\cs_generate_variant:Nn \groupthm_new_family_options:nnnn { n n n V }
\cs_generate_variant:Nn \groupthm_renew_family_options:nnnn { n n n V }
\cs_generate_variant:Nn \groupthm_provide_family_options:nnnn { n n n V }
\cs_generate_variant:Nn \groupthm_declare_family_options:nnnn { n n n V }
% \end{macrocode}
% \end{macro}
%
@ -2683,23 +2580,35 @@
% \end{syntax}
%
% \begin{macrocode}
\NewDocumentCommand { \NewGroupedTheoremFamilyOptions } { s m m m }
\@@_wrap_multiple_document:nnnn
{ new, renew, provide, declare }
{ \Declarator GroupedTheoremFamilyOptions }
{ s O{} m m m }
{
\IfBooleanTF { #1 }
\keys_set:nn { groupthm / theorem ~ family ~ options } { starred ~ version }
\keys_set:nn { groupthm / theorem ~ family ~ options } { ##2 }
\bool_if:nTF { ##1 }
{
\groupthm_new_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
\clist_set:Nn \l_tmpa_clist { unnumbered }
}
{
\groupthm_new_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
\clist_clear:N \l_tmpa_clist
}
\use:c { groupthm_#1_family_options:nnnV }
{ ##3 }
{ ##4 }
{ ##5 }
\l_tmpa_clist
\bool_if:NT \l_@@_starred_version_bool
{
\use:c { groupthm_#1_family_options:nnnV }
{ ##3* }
{ ##4 }
{
##5
\groupthm_add_theorem_to_group:n { starred }
}
\l_tmpa_clist
}
}
% \end{macrocode}
@ -2707,222 +2616,6 @@
%
%
%
% \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}
%
%
%
%
%
%
% \begin{macrocode}

View file

@ -128,6 +128,13 @@
unknown .code:n =
\msg_error:nnn { groupthm } { unknown ~ key } { \l_keys_key_str }
}
\keys_define:nn { groupthm / theorem ~ family ~ options }
{
starred ~ version .bool_set:N = \l__groupthm_key_starred_version_bool,
starred ~ version .default:n = { true },
unknown .code:n =
\msg_error:nnn { groupthm } { unknown ~ key } { \l_keys_key_str }
}
\cs_new:Npn \__groupthm_set_normalized_keys:nnn #1 #2 #3
{
\keys_set:nn { groupthm / theorem ~ group }
@ -284,7 +291,12 @@
\tl_log:n { Declarator ~ was ~ #1. }
#5 { #3 }
}
\cs_if_exist:NTF #4
\bool_if:nTF
{
\cs_if_exist_p:N #4
&&
\str_if_eq_p:nn { #1 } { provide }
}
{
\tl_log:n { Providing ~ #2 ~ '#3' ~ skipped: ~ '#3' ~ already ~ defined. }
}
@ -635,9 +647,9 @@
{
\groupthm_add_theorem_to_group:n { #1 }
}
\cs_new:Npn \__groupthm_declare_theorem_family_options_aux:nnnnn #1 #2 #3 #4 #5
\cs_new:Npn \__groupthm_define_family_options:nnnn #1 #2 #3 #4
{
\use:c{ #5 DocumentEnvironment }
\DeclareDocumentEnvironment
{ #1 }
{ #2 }
{
@ -667,204 +679,47 @@
\end { __#1__groups_ \clist_use:Nn \l__groupthm_group_clist { _ } }
}
}
\cs_new:Npn \groupthm_new_grouped_theorem_family_options:nnn #1 #2 #3
\__groupthm_define_multiple:nnnNNnn
{ new, renew, provide, declare }
{ theorem ~ family ~ options }
{ ##1 }
\use_none:n
\__groupthm_define_family_options:nnnn
{ groupthm_#1_family_options:nnnn }
{ { ##1 } { ##2 } { ##3 } { ##4 } }
\cs_generate_variant:Nn \groupthm_new_family_options:nnnn { n n n V }
\cs_generate_variant:Nn \groupthm_renew_family_options:nnnn { n n n V }
\cs_generate_variant:Nn \groupthm_provide_family_options:nnnn { n n n V }
\cs_generate_variant:Nn \groupthm_declare_family_options:nnnn { n n n V }
\__groupthm_wrap_multiple_document:nnnn
{ new, renew, provide, declare }
{ \Declarator GroupedTheoremFamilyOptions }
{ s O{} m m m }
{
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { New }
}
\cs_new:Npn \groupthm_renew_grouped_theorem_family_options:nnn #1 #2 #3
\keys_set:nn { groupthm / theorem ~ family ~ options } { starred ~ version }
\keys_set:nn { groupthm / theorem ~ family ~ options } { ##2 }
\bool_if:nTF { ##1 }
{
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Renew }
}
\cs_new:Npn \groupthm_provide_grouped_theorem_family_options:nnn #1 #2 #3
{
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Provide }
}
\cs_new:Npn \groupthm_declare_grouped_theorem_family_options:nnn #1 #2 #3
{
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Declare }
}
\cs_new:Npn \groupthm_new_theorem_family_options:nnn #1 #2 #3
{
\__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_theorem_family_options:nnn #1 #2 #3
{
\__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_theorem_family_options:nnn #1 #2 #3
{
\__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_theorem_family_options:nnn #1 #2 #3
{
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Declare }
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1* } { #2 } { #3 } { starred } { Declare }
}
\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 }
}
\clist_set:Nn \l_tmpa_clist { unnumbered }
}
{
\groupthm_new_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
\clist_clear:N \l_tmpa_clist
}
\use:c { groupthm_#1_family_options:nnnV }
{ ##3 }
{ ##4 }
{ ##5 }
\l_tmpa_clist
\bool_if:NT \l__groupthm_starred_version_bool
{
\use:c { groupthm_#1_family_options:nnnV }
{ ##3* }
{ ##4 }
{
##5
\groupthm_add_theorem_to_group:n { starred }
}
\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 }
}
}
\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 }
}
}
\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 }
}
}
\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 }
\l_tmpa_clist
}
}
\endinput