document and rework theorem groups
This commit is contained in:
parent
453471eb88
commit
6976cec905
2 changed files with 767 additions and 17 deletions
|
@ -2,6 +2,9 @@ all: clean pdf
|
|||
|
||||
pdf:
|
||||
pdflatex groupthm.dtx
|
||||
makeindex -s gind.ist groupthm.idx
|
||||
pdflatex groupthm.dtx
|
||||
pdflatex groupthm.dtx
|
||||
|
||||
clean:
|
||||
latexmk -c groupthm.dtx
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
% \fi
|
||||
%
|
||||
% \title{^^A
|
||||
% The \pkg{l3prop} package\\ Property lists^^A
|
||||
% The \pkg{groupthm} package^^A
|
||||
% }
|
||||
%
|
||||
% \author{^^A
|
||||
|
@ -53,6 +53,10 @@
|
|||
% {%
|
||||
% \emph{#1}%
|
||||
% }
|
||||
% \NewDocumentCommand{\ma}{m}
|
||||
% {
|
||||
% \{\meta{#1}\}
|
||||
% }
|
||||
%
|
||||
% \begin{documentation}
|
||||
%
|
||||
|
@ -363,7 +367,7 @@
|
|||
%
|
||||
% \subsection{Default theorem groups}
|
||||
%
|
||||
% There are a number of theorem groups that \pkg{group them} will initially declare
|
||||
% There are a number of theorem groups that \pkg{groupthm} will initially declare
|
||||
% and that have certain special treatment in some places.
|
||||
%
|
||||
% \begin{function}{all}
|
||||
|
@ -386,7 +390,7 @@
|
|||
% \todoref{}
|
||||
%
|
||||
% It is the highest theorem group in the hierarchy by default,
|
||||
% except for \cs{unnumbered},
|
||||
% except for \texttt{unnumbered},
|
||||
% with which it has no relation.
|
||||
% \end{function}
|
||||
% \addtocounter{footnote}{-1}
|
||||
|
@ -585,7 +589,7 @@
|
|||
% which enables the corresponding groups.
|
||||
%
|
||||
% When the environment is called within the document, the options are parsed
|
||||
% as with \pkg{xpars} and the \meta{selection body} is executed.
|
||||
% as with \pkg{xparse} and the \meta{selection body} is executed.
|
||||
% Immediately after, the theorem variant of \meta{theorem name} with the specified groups
|
||||
% by \cs{AddTheoremToGroup} is called.
|
||||
%
|
||||
|
@ -641,6 +645,10 @@
|
|||
% \NewTheoremFamilyOptions*, \RenewTheoremFamilyOptions*,
|
||||
% \ProvideTheoremFamilyOptions*, \DeclareTheoremFamilyOptions*
|
||||
% }
|
||||
% \begin{syntax}
|
||||
% \cs{NewTheoremFamilyOptions*}\{\meta{theorem name}\}\{\meta{argument specifiation}\}%
|
||||
% \{\meta{selection body}\}
|
||||
% \end{syntax}
|
||||
%
|
||||
% Combines the behavior of \cs{NewGroupedTheoremFamilyOptions*} and \cs{NewTheoremFamilyOptions},
|
||||
% thus declaring both \meta{theorem name} and \meta{theorem name*} environments,
|
||||
|
@ -654,14 +662,145 @@
|
|||
%
|
||||
% \section{\LaTeX3 interface}
|
||||
%
|
||||
% There is also an underlying \LaTeX3 interface provided by the package
|
||||
% (and in fact, all prior documented macros are just wrappers around this
|
||||
% internal programming interface.
|
||||
%
|
||||
% When building on top of this package, you can also use this interface,
|
||||
% which is possibly easier to use.
|
||||
%
|
||||
% In general, for functions that use key-value syntax, there are typically
|
||||
% three (public) versions of the command, namely
|
||||
%
|
||||
% \begin{itemize}
|
||||
% \item A \LaTeX3 command that requires all key-values as mandatory arguments,
|
||||
% so this does not use the key-value interface.
|
||||
% Use this if you already know with which keys you deal and know their
|
||||
% corresponding values.
|
||||
% \item A \LaTeX3 command having the first argument accepting the keys as a
|
||||
% comma-separated list.
|
||||
% Use this if you want to profit of the key-value syntax.
|
||||
% \item A \LaTeX2e document command. These were documented before,
|
||||
% and these just wrap the second type of command.
|
||||
% \end{itemize}
|
||||
% If the corresponding command would be something like \enquote{new foo},
|
||||
% The syntax will typically be
|
||||
% \begin{itemize}
|
||||
% \item \cs{groupthm_new_foo:mmm}\meta{mandatory args}\meta{optional args},
|
||||
% where the \meta{mandatory args} list the mandatory args of the \LaTeX2e
|
||||
% interface, and the \meta{optional args} list the optional args
|
||||
% of the key-value interface, but requiring them mandatory as well.
|
||||
% \item \cs{groupthm_new_foo_from_keys:mmm}\{\meta{keys}\}\meta{mandatory args}
|
||||
% where we pass a \texttt{clist} as the first argument and all mandatory args
|
||||
% as further mandatory arguments.
|
||||
% \item \cs{NewFoo}[\meta{keys}]\meta{mandatory args},
|
||||
% where the keys can be passed optionally.
|
||||
% \end{itemize}
|
||||
%
|
||||
% \subsection{Theorem groups}
|
||||
%
|
||||
%
|
||||
% \begin{function}{\groupthm_new_theorem_group_by_keys:nn}
|
||||
% \begin{syntax}
|
||||
% \cs{groupthm_new_theorem_group_by_keys:nn}\ma{keys}\ma{theorem group}
|
||||
% \end{syntax}
|
||||
%
|
||||
% \LaTeX3 version of \cs{NewTheoremGroup}
|
||||
%
|
||||
% \end{function}
|
||||
%
|
||||
%
|
||||
%
|
||||
% \begin{function}{\groupthm_renew_theorem_group_by_keys:nn}
|
||||
% \begin{syntax}
|
||||
% \cs{groupthm_renew_theorem_group_by_keys:nn}\ma{keys}
|
||||
% \ma{theorem group}
|
||||
% \end{syntax}
|
||||
%
|
||||
% \LaTeX3 version of \cs{RenewTheoremGroup}
|
||||
%
|
||||
% \end{function}
|
||||
%
|
||||
%
|
||||
%
|
||||
% \begin{function}{\groupthm_provide_theorem_group_by_keys:nn}
|
||||
% \begin{syntax}
|
||||
% \cs{groupthm_provide_theorem_group_by_keys:nn}
|
||||
% \ma{keys}\ma{theorem group}
|
||||
% \end{syntax}
|
||||
%
|
||||
% \LaTeX3 version of \cs{ProvideTheoremGroup}
|
||||
%
|
||||
% \end{function}
|
||||
%
|
||||
%
|
||||
%
|
||||
% \begin{function}{\groupthm_declare_theorem_group_by_keys:nn}
|
||||
% \begin{syntax}
|
||||
% \cs{groupthm_declare_theorem_group_by_keys:nn}
|
||||
% \ma{keys}\ma{theorem group}
|
||||
% \end{syntax}
|
||||
%
|
||||
% \LaTeX3 version of \cs{DeclareTheoremGroup}
|
||||
%
|
||||
% \end{function}
|
||||
%
|
||||
%
|
||||
%
|
||||
% \begin{function}{\groupthm_new_theorem_group:nnnnn, \groupthm_new_theorem_group:nVVVV}
|
||||
% \begin{syntax}
|
||||
% \cs{groupthm_new_theorem_group:nnnnn}\ma{theorem group}\ma{prename tl}
|
||||
% \ma{postname tl}\ma{mapname clist}\ma{thmtools clist}
|
||||
% \end{syntax}
|
||||
%
|
||||
% Non-keyval version of \cs{groupthm_new_theorem_group_by_keys:nn}
|
||||
%
|
||||
% \end{function}
|
||||
%
|
||||
%
|
||||
%
|
||||
% \begin{function}{\groupthm_renew_theorem_group:nnnnn, \groupthm_renew_theorem_group:nVVVV}
|
||||
% \begin{syntax}
|
||||
% \cs{groupthm_renew_theorem_group:nnnnn}\ma{theorem group}\ma{prename tl}
|
||||
% \ma{postname tl}\ma{mapname clist}\ma{thmtools clist}
|
||||
% \end{syntax}
|
||||
%
|
||||
% Non-keyval version of \cs{groupthm_renew_theorem_group_by_keys:nn}
|
||||
%
|
||||
% \end{function}
|
||||
%
|
||||
%
|
||||
% \begin{function}{\groupthm_provide_theorem_group:nnnnn, \groupthm_provide_theorem_group:nVVVV}
|
||||
% \begin{syntax}
|
||||
% \cs{groupthm_provide_theorem_group:nnnnn}\ma{theorem group}\ma{prename tl}
|
||||
% \ma{postname tl}\ma{mapname clist}\ma{thmtools clist}
|
||||
% \end{syntax}
|
||||
%
|
||||
% Non-keyval version of \cs{groupthm_provide_theorem_group_by_keys:nn}
|
||||
%
|
||||
% \end{function}
|
||||
%
|
||||
%
|
||||
% \begin{function}{\groupthm_declare_theorem_group:nnnnn, \groupthm_declare_theorem_group:nVVVV}
|
||||
% \begin{syntax}
|
||||
% \cs{groupthm_declare_theorem_group:nnnnn}\ma{theorem group}\ma{prename tl}
|
||||
% \ma{postname tl}\ma{mapname clist}\ma{thmtools clist}
|
||||
% \end{syntax}
|
||||
%
|
||||
% Non-keyval version of \cs{groupthm_declare_theorem_group_by_keys:nn}
|
||||
%
|
||||
% \end{function}
|
||||
%
|
||||
%
|
||||
%
|
||||
%
|
||||
%
|
||||
%
|
||||
% \begin{implementation}
|
||||
%
|
||||
% \section{\pkg{l3prop} implementation}
|
||||
% \section{\pkg{groupthm} implementation}
|
||||
%
|
||||
% \begin{macrocode}
|
||||
% \end{macrocode}
|
||||
% \error
|
||||
% \begin{macrocode}
|
||||
%<*package>
|
||||
% \end{macrocode}
|
||||
%
|
||||
|
@ -669,12 +808,620 @@
|
|||
%<@@=groupthm>
|
||||
% \end{macrocode}
|
||||
%
|
||||
% \subsection{Dependencies}
|
||||
% First, we import other packages on which we rely on, and
|
||||
% set up some private wrappers around these.
|
||||
% \begin{macrocode}
|
||||
\RequirePackage{amsthm}
|
||||
\RequirePackage{thmtools}
|
||||
\RequirePackage{mkessler-powerset}
|
||||
% \end{macrocode}
|
||||
%
|
||||
% \begin{macro}{\@@_declare_theorem_group:nn, \@@_declare_theorem_group:nV}
|
||||
% \begin{syntax}
|
||||
% \cs{@@_declare_theorem_group:nn} \meta{theorem name}\meta{thmtools keyval args}
|
||||
% \end{syntax}
|
||||
%
|
||||
% This is just a private wrapper around \cs{declaretheorem} of the \pkg{thmtools} package.
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\cs_new:Npn \@@_declare_theorem_group:nn #1 #2
|
||||
{
|
||||
\declaretheorem [ #2 ] { #1 }
|
||||
}
|
||||
\cs_generate_variant:Nn \@@_declare_theorem_group:nn { n V }
|
||||
% \end{macrocode}
|
||||
% \end{macro}
|
||||
%
|
||||
%
|
||||
%
|
||||
%
|
||||
%
|
||||
% \subsection{Messages}
|
||||
% These are messages that we might emit.
|
||||
%
|
||||
% When an unknown group is used somwhere:
|
||||
% \begin{syntax}
|
||||
% \cs{msg_error:nnn}\{ groupthm \}\{ unknown group \}\{\meta{groupname}\}
|
||||
% \end{syntax}
|
||||
% \begin{macrocode}
|
||||
\msg_new:nnn { groupthm } { unknown ~ group }
|
||||
{
|
||||
Unknown ~ group ~ '#1' ~ supplied ~ \msg_line_context:
|
||||
}
|
||||
% \end{macrocode}
|
||||
%
|
||||
% When an unknown key has been used:
|
||||
% \begin{syntax}
|
||||
% \cs{msg_error:nnn}\{ groupthm \}\{ unknown key \}\{\meta{key}\}
|
||||
% \end{syntax}
|
||||
% \begin{macrocode}
|
||||
\msg_new:nnn { groupthm } { unknown ~ key }
|
||||
{
|
||||
Unknown ~ key ~ '#1' ~ supplied ~ \msg_line_context:
|
||||
}
|
||||
% \end{macrocode}
|
||||
%
|
||||
% Some data structure is already defined or not defined yet.
|
||||
% \begin{syntax}
|
||||
% \cs{msg_error:nnnnn}\{ groupthm \}\{ wrong definition \}
|
||||
% \{\meta{type}\}\{\meta{name}\}\{\meta{already $\|$ not}\}
|
||||
% \end{syntax}
|
||||
% \begin{macrocode}
|
||||
\msg_new:nnn { groupthm } { wrong ~ definition }
|
||||
{
|
||||
Bad definition of #1 ~ '#2' ~ \msg_line_context:, #1 ~ is ~ #3 defined.
|
||||
}
|
||||
% \end{macrocode}
|
||||
%
|
||||
%
|
||||
%
|
||||
%
|
||||
% \subsection{Allocation and initialization}
|
||||
%
|
||||
% We use hooks at several places. However, these are not intended for outer use,
|
||||
% and we thus mark them with a preceding \texttt{__}.
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\hook_new:n { @@/prename }
|
||||
\hook_new:n { @@/postname }
|
||||
\hook_new:n { @@/mapname }
|
||||
\hook_new:n { @@/thmtools }
|
||||
% \end{macrocode}
|
||||
% \begin{macrocode}
|
||||
\hook_new:n { @@/groupsort }
|
||||
% \end{macrocode}
|
||||
%
|
||||
% \begin{macro}{\hook_gset_rule:nnVn}
|
||||
% \begin{syntax}
|
||||
% \cs{hook_gset_rule:nnVn}\{\meta{hook}\}\{\meta{label 1}\}\{\meta{relation}\}\{\meta{label 2}\}
|
||||
% \end{syntax}
|
||||
%
|
||||
% Just a variant of the usual \cs{hook_gset_rule:nnnn} macro that we use.
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\cs_generate_variant:Nn \hook_gset_rule:nnnn { n n V n }
|
||||
% \end{macrocode}
|
||||
% \end{macro}
|
||||
%
|
||||
%
|
||||
%
|
||||
% \begin{variable}
|
||||
% {
|
||||
% \l_@@_key_prename_tl, \l_@@_key_name_tl, \l_@@_key_postname_tl,
|
||||
% \l_@@_key_group_clist, \l_@@_key_mapname_clist, \l_@@_key_thmtools_clist
|
||||
% }
|
||||
% These variables will be set by the key-value interface provided by
|
||||
% \pkg{l3keys} and are used in various places in the package.
|
||||
% \begin{macrocode}
|
||||
\tl_new:N \l_@@_key_prename_tl
|
||||
\tl_new:N \l_@@_key_name_tl
|
||||
\tl_new:N \l_@@_key_postname_tl
|
||||
\clist_new:N \l_@@_key_group_clist
|
||||
\clist_new:N \l_@@_key_mapname_clist
|
||||
\clist_new:N \l_@@_key_thmtools_clist
|
||||
% \end{macrocode}
|
||||
% \end{variable}
|
||||
%
|
||||
% \begin{variable}
|
||||
% {
|
||||
% \l_@@_prename_tl,
|
||||
% \l_@@_name_tl,
|
||||
% \l_@@_postname_tl,
|
||||
% \l_@@_mapname_clist,
|
||||
% \l_@@_thmtools_clist,
|
||||
% \l_@@_group_clist
|
||||
% }
|
||||
%
|
||||
% General local variables.
|
||||
% Will typically be used to extract the variables set by the \pkg{l3keys} interface,
|
||||
% but also in just a local variable sense.
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\tl_new:N \l_@@_prename_tl
|
||||
\tl_new:N \l_@@_name_tl
|
||||
\tl_new:N \l_@@_postname_tl
|
||||
\clist_new:N \l_@@_mapname_clist
|
||||
\clist_new:N \l_@@_thmtools_clist
|
||||
\clist_new:N \l_@@_group_clist
|
||||
% \end{macrocode}
|
||||
% \end{variable}
|
||||
%
|
||||
%
|
||||
%
|
||||
% \begin{variable}{\g_@@_defined_theorem_groups_clist}
|
||||
%
|
||||
% This variable will hold a global list of declared theorem groups
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\clist_new:N \g_@@_defined_theorem_groups_clist
|
||||
% \end{macrocode}
|
||||
% \end{variable}
|
||||
%
|
||||
%
|
||||
%
|
||||
% \subsection{Key interface}
|
||||
% As mentioned, all keys will set their corresponding local variables
|
||||
% (containing \enquote{\texttt{_key_}} in their name) and store the
|
||||
% user input in these.
|
||||
%
|
||||
% Additionally, we group these keys by use cases,
|
||||
% and provide defaults that in most cases will not require further handling.
|
||||
%
|
||||
%
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\keys_define:nn { groupthm }
|
||||
{
|
||||
prename .tl_set:N = \l_@@_key_prename_tl,
|
||||
prename .default:n = \c_empty_tl,
|
||||
prename .groups:n = { theoremgroup },
|
||||
name .tl_set:N = \l_@@_key_name_tl,
|
||||
name .default:n = \c_novalue_tl,
|
||||
name .groups:n = { groupedtheorem, theoremvariants },
|
||||
postname .tl_set:N = \l_@@_key_postname_tl,
|
||||
postname .default:n = \c_empty_tl,
|
||||
postname .groups:n = { theoremgroup },
|
||||
group .clist_set:N = \l_@@_key_group_clist,
|
||||
group .default:n = {},
|
||||
group .groups:n = { groupedtheorem, theoremvariants },
|
||||
mapname .clist_set:N = \l_@@_mapname_clist,
|
||||
mapname .default:n = {},
|
||||
mapname .groups:n = { theoremgroup },
|
||||
thmtools .clist_set:N = \l_@@_key_thmtools_clist,
|
||||
thmtools .default:n = {},
|
||||
thmtools .groups:n =
|
||||
{ theoremgroup, groupedtheorem, theoremvariants },
|
||||
unknown .code:n =
|
||||
\msg_error:nnn { groupthm } { unknown ~ group } { \l_keys_key_str }
|
||||
}
|
||||
% \end{macrocode}
|
||||
%
|
||||
%
|
||||
% The only key whose default requires such handling is the \enquote{\texttt{name}} key,
|
||||
% which will be set to a capitalized version of the environment name
|
||||
% when not specified.
|
||||
%
|
||||
%
|
||||
% \begin{macro}{\@@_set_normalized_keys:nnn}
|
||||
% \begin{syntax}
|
||||
% \cs{@@_set_normalized_keys:nnn}\ma{keys}\ma{key group}\ma{fallback name}
|
||||
% \end{syntax}
|
||||
%
|
||||
% Sets the packages keys and normalizes the retrieved values, that is,
|
||||
% clears old set keys, stores all keys in local variables,
|
||||
% and replaces the \cs{l_@@_name_tl} with the capitalized version of the
|
||||
% \meta{fallback name}.
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\cs_new:Npn \@@_set_normalized_keys:nnn #1 #2 #3
|
||||
{
|
||||
\keys_set:nn { @@ } { prename, name, postname, group, mapname, thmtools }
|
||||
\keys_set_groups:nnn { @@ } { #2 } { #1 }
|
||||
% \end{macrocode}
|
||||
%
|
||||
% Normalize given name
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\tl_if_eq:NnTF \l_@@_key_name_tl { \c_novalue_tl }
|
||||
{
|
||||
\tl_set:Nx \l_@@_name_tl
|
||||
{
|
||||
\text_titlecase_first:n {#3}
|
||||
}
|
||||
}
|
||||
{
|
||||
\tl_set_eq:NN \l_@@_name_tl \l_@@_key_name_tl
|
||||
}
|
||||
% \end{macrocode}
|
||||
%
|
||||
% Copy set keys into local variables
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\tl_set_eq:NN \l_@@_prename_tl \l_@@_key_prename_tl
|
||||
\tl_set_eq:NN \l_@@_postname_tl \l_@@_key_postname_tl
|
||||
\clist_set_eq:NN \l_@@_group_clist \l_@@_key_group_clist
|
||||
\clist_set_eq:NN \l_@@_mapname_clist \l_@@_key_mapname_clist
|
||||
\clist_set_eq:NN \l_@@_thmtools_clist \l_@@_key_group_clist
|
||||
}
|
||||
% \end{macrocode}
|
||||
% \end{macro}
|
||||
%
|
||||
%
|
||||
% \subsection{Theorem groups}
|
||||
%
|
||||
%
|
||||
% \begin{macro}{\@@_declare_theorem_group_aux:nnnnn}
|
||||
% \begin{syntax}
|
||||
% \cs{@@_declare_theorem_group_aux:nnnnn}\{\meta{theorem group}\}\{\meta{prename tl}\}
|
||||
% \{\meta{postname tl}\}\{\meta{mapname clist}\}\{\meta{thmtools clist}\}
|
||||
% \end{syntax}
|
||||
%
|
||||
% This creates a new theorem group out of the given parameters.
|
||||
% We store all given contents in our (private) hooks, using the group name as the key
|
||||
% so that we can later retrieve the components of each group separately.
|
||||
%
|
||||
% This is an internal function and assumes that the group is currently not defined,
|
||||
% and also removed from all hooks.
|
||||
%
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\cs_new:Npn \@@_declare_theorem_group_aux:nnnnn #1#2#3#4#5
|
||||
{
|
||||
% \end{macrocode}
|
||||
%
|
||||
% \begin{macro}{\@@_use_group_#:}
|
||||
%
|
||||
% This is the internal macro that will be called when retrieving contents of a group.
|
||||
% We define this here to store the properties of the group.
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\cs_new:cpn { @@_use_group_#1: }
|
||||
{
|
||||
\hook_gput_code:nnn { @@/prename } { #1 }
|
||||
{
|
||||
\tl_put_left:Nx \l_@@_prename_tl { #2 }
|
||||
}
|
||||
\hook_gput_code:nnn { @@/postname } { #1 }
|
||||
{
|
||||
\tl_put_right:Nx \l_@@_postname_tl { #3 }
|
||||
}
|
||||
\hook_gput_code:nnn { @@/mapname } { #1 }
|
||||
{
|
||||
\clist_put_right:Nn \l_@@_mapname_clist { #4 }
|
||||
}
|
||||
\hook_gput_code:nnn { @@/thmtools } { #1 }
|
||||
{
|
||||
\clist_put_right:Nn \l_@@_thmtools_clist { #5 }
|
||||
}
|
||||
}
|
||||
% \end{macrocode}
|
||||
% \end{macro}
|
||||
%
|
||||
% This ensures some ordering hacks explained later.
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\@@_update_ordering:n { #1 }
|
||||
% \end{macrocode}
|
||||
%
|
||||
% Add defined group to corresponding list
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\clist_gput_left:Nn \g_@@_defined_theorem_groups_clist { #1 }
|
||||
}
|
||||
% \end{macrocode}
|
||||
% \end{macro}
|
||||
%
|
||||
%
|
||||
% \begin{macro}{\@@_undeclare_theorem_group_aux:n}
|
||||
% \begin{syntax}
|
||||
% \cs{@@_undeclare_theorem_group_aux:n}\ma{theorem group}
|
||||
% \end{syntax}
|
||||
%
|
||||
% Undeclares / undefines the given theorem group.
|
||||
% This means removing its hook code in the \texttt{prename}, \texttt{postname},
|
||||
% \texttt{mapname} and \texttt{thmtools} hooks,
|
||||
% and removing all relations with other theorem groups globally
|
||||
% as well as for each hook individually.
|
||||
%
|
||||
% This macro assumes that the group was defined prior to calling.
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\cs_new:Npn \@@_undeclare_theorem_group_aux:n #1
|
||||
{
|
||||
\cs_undefine:c { @@_use_group_#1: }
|
||||
% \end{macrocode}
|
||||
%
|
||||
% Remove properties from hooks
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\hook_gremove_code:nn { @@/prename }
|
||||
\hook_gremove_code:nn { @@/postname }
|
||||
\hook_gremove_code:nn { @@/mapname }
|
||||
\hook_gremove_code:nn { @@/thmtools }
|
||||
% \end{macrocode}
|
||||
%
|
||||
% Remove theorem group from list of defined theorems
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\clist_remove_all:Nn \g_@@_defined_theorem_groups_clist { #1 }
|
||||
% \end{macrocode}
|
||||
%
|
||||
% Now, unset all relations with all defined theorem groups in the internal hooks.
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\@@_hook_gset_rule_foreach:nNnn
|
||||
{ ?? }
|
||||
\g_@@_defined_theorem_groups_clist { #1 }
|
||||
{ unrelated }
|
||||
{ #1 }
|
||||
\@@_hook_gset_rule_foreach:nNnn
|
||||
{ @@/prename }
|
||||
\g_@@_defined_theorem_groups_clist { #1 }
|
||||
{ unrelated }
|
||||
{ #1 }
|
||||
\@@_hook_gset_rule_foreach:nNnn
|
||||
{ @@/postname }
|
||||
\g_@@_defined_theorem_groups_clist { #1 }
|
||||
{ unrelated }
|
||||
{ #1 }
|
||||
\@@_hook_gset_rule_foreach:nNnn
|
||||
{ @@/mapname }
|
||||
\g_@@_defined_theorem_groups_clist { #1 }
|
||||
{ unrelated }
|
||||
{ #1 }
|
||||
\@@_hook_gset_rule_foreach:nNnn
|
||||
{ @@/thmtools }
|
||||
\g_@@_defined_theorem_groups_clist { #1 }
|
||||
{ unrelated }
|
||||
{ #1 }
|
||||
\@@_hook_gset_rule_foreach:nNnn
|
||||
{ @@/groupsort }
|
||||
\g_@@_defined_theorem_groups_clist { #1 }
|
||||
{ unrelated }
|
||||
{ #1 }
|
||||
}
|
||||
% \end{macrocode}
|
||||
% \end{macro}
|
||||
%
|
||||
% With these two helper functions, we can now easily implement the
|
||||
% \texttt{new}, \texttt{renew}, \texttt{provide} and \texttt{declare} variants
|
||||
% of the theorem group macro:
|
||||
%
|
||||
% \begin{macro}{\groupthm_new_theorem_group:nnnnn, \groupthm_new_theorem_group:nVVVV}
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\cs_new:Npn \groupthm_new_theorem_group:nnnnn #1 #2 #3 #3 #5
|
||||
{
|
||||
\cs_if_exist:cTF { @@_use_group_#1 }
|
||||
{
|
||||
\msg_error:nnnnn { groupthm } { wrong ~ definition }
|
||||
{ group } { #1 } { already }
|
||||
}
|
||||
{
|
||||
\@@_declare_theorem_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 }
|
||||
}
|
||||
}
|
||||
% \end{macrocode}
|
||||
%
|
||||
% Finally, generate some extra variant.
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\cs_generate_variant:Nn \groupthm_new_theorem_group:nnnnn { n V V V V }
|
||||
% \end{macrocode}
|
||||
% \end{macro}
|
||||
%
|
||||
%
|
||||
%
|
||||
% \begin{macro}{\groupthm_renew_theorem_group:nnnnn, \groupthm_renew_theorem_group:nVVVV}
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\cs_new:Npn \groupthm_renew_theorem_group:nnnnn #1 #2 #3 #3 #5
|
||||
{
|
||||
\cs_if_exist:cTF { @@_use_group_#1 }
|
||||
{
|
||||
\@@_undeclare_theorem_group_aux:n { #1 }
|
||||
\@@_declare_theorem_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 }
|
||||
}
|
||||
{
|
||||
\msg_error:nnnnn { groupthm } { wrong ~ definition }
|
||||
{ group } { #1 } { not }
|
||||
}
|
||||
}
|
||||
% \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 #3 #5
|
||||
{
|
||||
\cs_if_exist:cF { @@_use_group_#1 }
|
||||
{
|
||||
\@@_declare_theorem_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 #3 #5
|
||||
{
|
||||
\cs_if_exist:cT { @@_use_group_#1 }
|
||||
{
|
||||
\@@_undeclare_theorem_group_aux:n { #1 }
|
||||
}
|
||||
\@@_declare_theorem_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,
|
||||
% it is also easy to provide key-value interfaces for these commands:
|
||||
%
|
||||
% \begin{macro}{\groupthm_new_theorem_group_by_keys:nn}
|
||||
% \begin{syntax}
|
||||
% \cs{groupthm_new_theorem_group_by_keys:nn}\ma{keys}\ma{theorem group}
|
||||
% \end{syntax}
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\cs_new:Npn \groupthm_new_theorem_group_by_keys:nn #1#2
|
||||
{
|
||||
\@@_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 }
|
||||
\groupthm_new_theorem_group:nVVVV { #1 }
|
||||
\l_@@_prename_tl
|
||||
\l_@@_postname_tl
|
||||
\l_@@_mapname_clist
|
||||
\l_@@_thmtools_clist
|
||||
}
|
||||
% \end{macrocode}
|
||||
% \end{macro}
|
||||
%
|
||||
%
|
||||
%
|
||||
% \begin{macro}{\groupthm_renew_theorem_group_by_keys:nn}
|
||||
% \begin{syntax}
|
||||
% \cs{groupthm_renew_theorem_group_by_keys:nn}\ma{keys}\ma{theorem group}
|
||||
% \end{syntax}
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\cs_new:Npn \groupthm_renew_theorem_group_by_keys:nn #1#2
|
||||
{
|
||||
\@@_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 }
|
||||
\groupthm_renew_theorem_group:nVVVV { #1 }
|
||||
\l_@@_prename_tl
|
||||
\l_@@_postname_tl
|
||||
\l_@@_mapname_clist
|
||||
\l_@@_thmtools_clist
|
||||
}
|
||||
% \end{macrocode}
|
||||
% \end{macro}
|
||||
%
|
||||
%
|
||||
%
|
||||
% \begin{macro}{\groupthm_provide_theorem_group_by_keys:nn}
|
||||
% \begin{syntax}
|
||||
% \cs{groupthm_provide_theorem_group_by_keys:nn}\ma{keys}\ma{theorem group}
|
||||
% \end{syntax}
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\cs_new:Npn \groupthm_provide_theorem_group_by_keys:nn #1#2
|
||||
{
|
||||
\@@_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 }
|
||||
\groupthm_provide_theorem_group:nVVVV { #1 }
|
||||
\l_@@_prename_tl
|
||||
\l_@@_postname_tl
|
||||
\l_@@_mapname_clist
|
||||
\l_@@_thmtools_clist
|
||||
}
|
||||
% \end{macrocode}
|
||||
% \end{macro}
|
||||
%
|
||||
%
|
||||
%
|
||||
% \begin{macro}{\groupthm_declare_theorem_group_by_keys:nn}
|
||||
% \begin{syntax}
|
||||
% \cs{groupthm_declare_theorem_group_by_keys:nn}\ma{keys}\ma{theorem group}
|
||||
% \end{syntax}
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\cs_new:Npn \groupthm_declare_theorem_group_by_keys:nn #1#2
|
||||
{
|
||||
\@@_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 }
|
||||
\groupthm_declare_theorem_group:nVVVV { #1 }
|
||||
\l_@@_prename_tl
|
||||
\l_@@_postname_tl
|
||||
\l_@@_mapname_clist
|
||||
\l_@@_thmtools_clist
|
||||
}
|
||||
% \end{macrocode}
|
||||
% \end{macro}
|
||||
%
|
||||
%
|
||||
% Finally, we provide \LaTeX2e wrappers as document commands for these.
|
||||
%
|
||||
%
|
||||
% \begin{macro}{\NewTheoremGroup}
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\NewDocumentCommand{\NewTheoremGroup}{ O{} m }
|
||||
{
|
||||
\groupthm_new_theorem_group_by_keys:nn { #1 } { #2 }
|
||||
}
|
||||
% \end{macrocode}
|
||||
% \end{macro}
|
||||
%
|
||||
%
|
||||
%
|
||||
% \begin{macro}{\RenewTheoremGroup}
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\NewDocumentCommand{\RenewTheoremGroup}{ O{} m }
|
||||
{
|
||||
\groupthm_renew_theorem_group_by_keys:nn { #1 } { #2 }
|
||||
}
|
||||
% \end{macrocode}
|
||||
% \end{macro}
|
||||
%
|
||||
%
|
||||
%
|
||||
% \begin{macro}{\ProvideTheoremGroup}
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\NewDocumentCommand{\ProvideTheoremGroup}{ O{} m }
|
||||
{
|
||||
\groupthm_provide_theorem_group_by_keys:nn { #1 } { #2 }
|
||||
}
|
||||
% \end{macrocode}
|
||||
% \end{macro}
|
||||
%
|
||||
%
|
||||
%
|
||||
% \begin{macro}{\DeclareTheoremGroup}
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\NewDocumentCommand{\DeclareTheoremGroup}{ O{} m }
|
||||
{
|
||||
\groupthm_declare_theorem_group_by_keys:nn { #1 } { #2 }
|
||||
}
|
||||
% \end{macrocode}
|
||||
% \end{macro}
|
||||
%
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
% \begin{macrocode}
|
||||
%</package>
|
||||
% \end{macrocode}
|
||||
%
|
||||
% \end{implementation}
|
||||
% \end{documentation}
|
||||
% \PrintIndex
|
||||
|
|
Loading…
Reference in a new issue