diff --git a/doc/environments/groupthm/Makefile b/doc/environments/groupthm/Makefile index 75c481b..7c7ee70 100644 --- a/doc/environments/groupthm/Makefile +++ b/doc/environments/groupthm/Makefile @@ -1,4 +1,4 @@ -sty: +sty: clean-sty pdflatex groupthm.ins all: clean pdf sty @@ -7,7 +7,6 @@ pdf: pdflatex groupthm.dtx makeindex -s gind.ist groupthm.idx pdflatex groupthm.dtx - pdflatex groupthm.dtx clean: clean-sty latexmk -c groupthm.dtx diff --git a/doc/environments/groupthm/groupthm.dtx b/doc/environments/groupthm/groupthm.dtx index adaa0bb..44c10d9 100644 --- a/doc/environments/groupthm/groupthm.dtx +++ b/doc/environments/groupthm/groupthm.dtx @@ -46,6 +46,16 @@ % \emph{#1}% % } % +% \ExplSyntaxOn +% \NewDocumentCommand { \mymeta } { O{} m } +% { +% \meta[#1]{#2} +% \__codedoc_special_index_module:nnnnN { #2 } { #2 } { meta } { usage } { \c_false_bool} +% } +% \ExplSyntaxOff +% +% +% % \begin{documentation} % % \tableofcontents @@ -74,14 +84,14 @@ % for almost all needs, it is pretty time-consuming to largely change % the behavior of environments, or have small variants of these. % -% This package aims at both providing a versatile mechanism, \meta{theorem group}s, +% This package aims at both providing a versatile mechanism, \mymeta{theorem group}s, % to structure theorems into groups that can subsequently easily altered, -% as well as a mechanism for easily generating \meta{theorem families}. +% as well as a mechanism for easily generating \mymeta{theorem families}. % % As the author is of the opinion that of the mentioned theorem controlling packages % \pkg{thmtools} provides the most versatile interface, the \pkg{groupthm} % will be working on top of \pkg{thmtools} and use this as a backend for declaring -% the \meta{theorem}s themselves. +% the \mymeta{theorem}s themselves. % % Thus, any styles supported by \pkg{thmtools} will be supported by \pkg{groupthm} % as well, by passing them to \pkg{thmtools}. @@ -90,46 +100,46 @@ % % \subsection{Theorem groups} % \label{sec:theorem-groups} -% A \meta{theorem group} is some named group holding some properties for -% the \meta{theorem}s that are contained in this group. -% Each \meta{theorem} can, when declared, be part of arbitrarily many \meta{theorem group}s, +% A \mymeta{theorem group} is some named group holding some properties for +% the \mymeta{theorem}s that are contained in this group. +% Each \mymeta{theorem} can, when declared, be part of arbitrarily many \mymeta{theorem group}s, % and will be subject to the styles these groups defined. % -% This enables to group similar \meta{theorem}s and alter them at a late stage of +% This enables to group similar \mymeta{theorem}s and alter them at a late stage of % document development in a unique manner, by only having to change the -% definition of the \meta{theorem group}, and not all \meta{theorem}s separately. +% definition of the \mymeta{theorem group}, and not all \mymeta{theorem}s separately. % -% The properties. such a \meta{theorem group} can hold are as follows +% The properties. such a \mymeta{theorem group} can hold are as follows % % % \begin{description} -% \item[\kw{prefix}] A prefix (any \meta{token list}) that will be inserted -% before the theorem name of each member of this \meta{theorem group}. -% \item[\kw{suffix}] A suffix (any \meta{token list}) that will be -% inserted before the theorem name for each member of this \meta{theorem group}. +% \item[\kw{prefix}] A prefix (any \mymeta{token list}) that will be inserted +% before the theorem name of each member of this \mymeta{theorem group}. +% \item[\kw{suffix}] A suffix (any \mymeta{token list}) that will be +% inserted before the theorem name for each member of this \mymeta{theorem group}. % This could be e.g.~some \enquote{$\star$} appended to the name to indicate % variants of environments. -% \item[\kw{mapname}] A \meta{function} (some macro that takes exactly one argument) +% \item[\kw{mapname}] A \mymeta{function} (some macro that takes exactly one argument) % that is applied to the \kw{name}. -% \item[\kw{thmtools}] A \meta{clist} of key-value pairs that are passed to the underlying -% \pkg{thmtools} backend of the \meta{theorem}. -% This allows e.g.~to set the \kw{topskip} of a certain class of \meta{theorem}s. +% \item[\kw{thmtools}] A \mymeta{clist} of key-value pairs that are passed to the underlying +% \pkg{thmtools} backend of the \mymeta{theorem}. +% This allows e.g.~to set the \kw{topskip} of a certain class of \mymeta{theorem}s. % \end{description} % % The most versatile key here is certainly the \kw{thmtools} key, % providing the most customization to an end user (like you). % -% As mentioned, each \meta{theorem} can be member of arbitrary many \meta{theorem group}s, +% As mentioned, each \mymeta{theorem} can be member of arbitrary many \mymeta{theorem group}s, % and will posses their corresponding properties. % -% To adjust finer controlling of these \meta{theorem group}s, \meta{theorem group}s can inherit from each other, and \meta{theorem group}s are subject to a hierarchy that controls precedence in case -% of conflicting properties of different \meta{theorem group}s a \meta{theorem} may be part of. +% To adjust finer controlling of these \mymeta{theorem group}s, \mymeta{theorem group}s can inherit from each other, and \mymeta{theorem group}s are subject to a hierarchy that controls precedence in case +% of conflicting properties of different \mymeta{theorem group}s a \mymeta{theorem} may be part of. % % This hierarchy can of course be controlled by the user. % % \subsection{Grouped theorems} % -% A \meta{grouped theorem} is just a theorem that is a member of +% A \mymeta{grouped theorem} is just a theorem that is a member of % a given set of groups (possibly empty). % It behaves just a regular theorem, except that by changing the definition of % its theorem groups, we can alter its behavior. @@ -140,8 +150,8 @@ % although in fact we mean \enquote{grouped theorems}. % % \subsection{Theorem families} -% Often, one needs some small \meta{theorem variant}s of some \meta{theorem}, the most typical -% example being \vocab{starred} version of \meta{theorem}s that are not numbered +% Often, one needs some small \mymeta{theorem variant}s of some \mymeta{theorem}, the most typical +% example being \vocab{starred} version of \mymeta{theorem}s that are not numbered % in contrast to their counterparts. % % \begin{verbatim} @@ -157,12 +167,12 @@ % \todo{insert code example output} % % \pkg{groupthm} extends this idea and provides a versatile mechanism to define a -% \meta{theorem family}, which is based on some \meta{theorem name} and -% parses additional arguments / syntax to control the \meta{theorem groups} +% \mymeta{theorem family}, which is based on some \mymeta{theorem name} and +% parses additional arguments / syntax to control the \mymeta{theorem groups} % that this environment is a part of. % -% So, in addition the name of a \meta{theorem}, the corresponding environment will -% accept some options and toggle the membership of certain \meta{theorem groups}, +% So, in addition the name of a \mymeta{theorem}, the corresponding environment will +% accept some options and toggle the membership of certain \mymeta{theorem groups}, % thus further customizing its appearance. % % This can lead e.g.~to usages like the following: @@ -175,10 +185,10 @@ % \todo{code} % % Providing this consists of two parts: -% declaring the \meta{theorem family} by listing the groups that can be toggled -% by this \meta{theorem family}, and declaring the actual option parsing -% of the \meta{theorem family}, which then controls the membership in these groups -% (and of course prior to this the definition of the desired \meta{theorem group}s). +% declaring the \mymeta{theorem family} by listing the groups that can be toggled +% by this \mymeta{theorem family}, and declaring the actual option parsing +% of the \mymeta{theorem family}, which then controls the membership in these groups +% (and of course prior to this the definition of the desired \mymeta{theorem group}s). % % % @@ -241,33 +251,33 @@ % \cs{NewTheoremGroup}\oarg{keys}\marg{theorem group} % \end{syntax} % -% This introduces a new \meta{theorem group} with the given name. -% The \meta{keys} available are the same as introduced in \autoref{sec:theorem-groups}: +% This introduces a new \mymeta{theorem group} with the given name. +% The \mymeta{keys} available are the same as introduced in \autoref{sec:theorem-groups}: % % \begin{description} % \item % -% \kw{prefix} = \meta{token list}. -% Insert the \meta{token list} in front of the theorem name. +% \kw{prefix} = \mymeta{token list}. +% Insert the \mymeta{token list} in front of the theorem name. % % \item % -% \kw{suffix} = \meta{token list}. -% Insert the \meta{token list} after the theorem name. +% \kw{suffix} = \mymeta{token list}. +% Insert the \mymeta{token list} after the theorem name. % % \item % -% \kw{mapname} = \meta{function}. -% Apply this \meta{function} to the theorem name. +% \kw{mapname} = \mymeta{function}. +% Apply this \mymeta{function} to the theorem name. % % \item % -% \kw{thmtools} = $\{$\meta{clist}$\}$. +% \kw{thmtools} = $\{$\mymeta{clist}$\}$. % Pass these options to \pkg{thmtools}. % % \end{description} % -% For uniqueness of the given options, the \meta{clist} given to the \kw{thmtools} key +% For uniqueness of the given options, the \mymeta{clist} given to the \kw{thmtools} key % has to be surrounded by a pair of braces. % % \begin{texnote} @@ -289,15 +299,15 @@ % controlling their order of application in case a theorem is member % of both groups. % -% The \meta{keyname} can be one of \kw{prefix}, \kw{suffix}, \kw{mapname}, \kw{thmtools}. +% The \mymeta{keyname} can be one of \kw{prefix}, \kw{suffix}, \kw{mapname}, \kw{thmtools}. % If present, it declares the corresponding relation only for this subkey. -% This can lead to \meta{theorem group 1} overwriting \meta{theorem group 2} when given -% contradictory \pkg{thmtools} options, but the \kw{prefix} of \meta{theorem group 1} -% being applied after the one of \meta{theorem group 2}. -% When the \meta{keyname} is not given, this applies to all keywords. +% This can lead to \mymeta{theorem group 1} overwriting \mymeta{theorem group 2} when given +% contradictory \pkg{thmtools} options, but the \kw{prefix} of \mymeta{theorem group 1} +% being applied after the one of \mymeta{theorem group 2}. +% When the \mymeta{keyname} is not given, this applies to all keywords. % % \begin{texnote} -% The \meta{keyname} is just passed to the corresponding argument +% The \mymeta{keyname} is just passed to the corresponding argument % of the \kw{lthooks} package. % If the option argument is not present, \kw{??} is used, this has the described effect. % \end{texnote} @@ -311,18 +321,18 @@ % \begin{description} % \item[\kw{higher} or \kw{after} or \kw{\string>}] % -% \meta{theorem group 1} takes precedence over \meta{theorem group 2}. -% Its \kw{prefix} is applied after the one of \meta{theorem group 2}. +% \mymeta{theorem group 1} takes precedence over \mymeta{theorem group 2}. +% Its \kw{prefix} is applied after the one of \mymeta{theorem group 2}. % % \item[\kw{lower} or \kw{before} or \kw{\string<}] % -% \meta{theorem group 2} takes precedence over \meta{theorem group 1}. -% Its \kw{prefix} is applied after the one of \meta{theorem group 1}. +% \mymeta{theorem group 2} takes precedence over \mymeta{theorem group 1}. +% Its \kw{prefix} is applied after the one of \mymeta{theorem group 1}. % % \end{description} % % \begin{texnote} -% The \meta{relation} is first stripped, +% The \mymeta{relation} is first stripped, % then checked if it matches either \kw{higher} or \kw{lower} % and in this case replaced by the corresponding \pkg{lthooks} variant % of the relation. @@ -338,22 +348,22 @@ % \begin{syntax} % \cs{AddTheoremGroupParent}\marg{theorem group 1}\marg{theorem group 2} % \end{syntax} -% Declares \meta{theorem group 1} to \enquote{inherit} all properties -% of \meta{theorem group 2}. -% In other words, \meta{theorem group 2} is a parent of \meta{theorem group 1} +% Declares \mymeta{theorem group 1} to \enquote{inherit} all properties +% of \mymeta{theorem group 2}. +% In other words, \mymeta{theorem group 2} is a parent of \mymeta{theorem group 1} % in a usual inheritance graph. % % The definitions of the groups themselves are unchanged, -% but each new theorem defined with \meta{theorem group 1} will also -% have the properties of \meta{theorem group 2}. +% but each new theorem defined with \mymeta{theorem group 1} will also +% have the properties of \mymeta{theorem group 2}. % % Inheritance is transitive, when defining a new theorem, we just flatten out the % inheritance graph and apply all properties. % % Inheritance is subject to the usual theorem group hierarchies as discussed in \todoref. -% This can even yield to situations, where \meta{theorem group 1} inherits -% from \meta{theorem group 2}, but \meta{theorem group 2} overwrites -% \meta{theorem group 1}. +% This can even yield to situations, where \mymeta{theorem group 1} inherits +% from \mymeta{theorem group 2}, but \mymeta{theorem group 2} overwrites +% \mymeta{theorem group 1}. % \end{function} % % \subsection{Appending to theorem groups} @@ -361,8 +371,8 @@ % \begin{syntax} % \cs{AppendToTheoremGroup}\oarg{keys}\marg{theorem group} % \end{syntax} -% Adds the properties given as \meta{keys} to the theorem group. -% The syntax for the \meta{keys} is the same as in \cs{NewTheoremGroup}. +% Adds the properties given as \mymeta{keys} to the theorem group. +% The syntax for the \mymeta{keys} is the same as in \cs{NewTheoremGroup}. % \end{function} % % \subsection{Default theorem groups} @@ -442,16 +452,16 @@ % \begin{syntax} % \cs{NewGroupedTheorem}\oarg{keys}\marg{theorem name} % \end{syntax} -% This defines \meta{theorem name} as a new theorem environment. +% This defines \mymeta{theorem name} as a new theorem environment. % Its properties can be set by the following keys: % % \begin{description} % % \item % -% \kw{name} $=$ \meta{displayed name}. +% \kw{name} $=$ \mymeta{displayed name}. % If given, this is the displayed name of the environment in the document. -% If not present, the \meta{theorem name} is also used as the \meta{displayed name} +% If not present, the \mymeta{theorem name} is also used as the \mymeta{displayed name} % in capitalized form. % % \item @@ -490,9 +500,9 @@ % \end{syntax} % % This behaves essentially the same as \cs{NewGroupedTheorem}, -% but will define two grouped theorems, namely \meta{theorem name} and \meta{theorem name*}. +% but will define two grouped theorems, namely \mymeta{theorem name} and \mymeta{theorem name*}. % -% The \meta{theorem name*} environment has the same properties as the \meta{theorem name}, +% The \mymeta{theorem name*} environment has the same properties as the \mymeta{theorem name}, % but will be member of the \kw{starred} theorem group. % It is thus not recommended to call \cs{NewTheorem} % with an actual \enquote{*} in the environment name, since both environments @@ -504,8 +514,8 @@ % \cs{NewTheorem}\oarg{keys}\marg{theorem name} % \end{syntax} % Combines the behavior of \cs{NewGroupedTheorem*} and \cs{NewTheorem}, thus -% declaring \meta{theorem} to (additionally) be member of the \kw{unnumbered} -% and \meta{theorem*} to (additionally) be member of the \kw{starred} group. +% declaring \mymeta{theorem} to (additionally) be member of the \kw{unnumbered} +% and \mymeta{theorem*} to (additionally) be member of the \kw{starred} group. % % As mentioned in \todoref, by default both environments will behave the same. % \end{function} @@ -518,7 +528,7 @@ % \end{syntax} % % Defines a family of grouped theorems. -% The \meta{keys} accept the same arguments as the \cs{NewGroupedTheorem} macro. +% The \mymeta{keys} accept the same arguments as the \cs{NewGroupedTheorem} macro. % However, for each \emph{subset} of the given groups, % a grouped theorem is defined. % @@ -577,11 +587,11 @@ % \marg{selection body} % \end{syntax} % -% Defines a new environment with options, given by \meta{theorem name}. -% The \meta{argument specification} can be any valid \pkg{xparse} argument specification. +% Defines a new environment with options, given by \mymeta{theorem name}. +% The \mymeta{argument specification} can be any valid \pkg{xparse} argument specification. % -% The \meta{selection body} is there to process the options of -% the \meta{argument specification} and select which variant of the \meta{theorem name} +% The \mymeta{selection body} is there to process the options of +% the \mymeta{argument specification} and select which variant of the \mymeta{theorem name} % to enter. % The arguments are available as usual with \pkg{xparse} by \kw{\#1}, \kw{\#2}, \ldots % @@ -589,11 +599,11 @@ % which enables the corresponding groups. % % When the environment is called within the document, the options are parsed -% as with \pkg{xparse} and the \meta{selection body} is executed. -% Immediately after, the theorem variant of \meta{theorem name} with the specified groups +% as with \pkg{xparse} and the \mymeta{selection body} is executed. +% Immediately after, the theorem variant of \mymeta{theorem name} with the specified groups % by \cs{AddTheoremToGroup} is called. % -% At the end of the environment, the \meta{selection body} is executed again and the +% At the end of the environment, the \mymeta{selection body} is executed again and the % called theorem variant is ended again. % % The possible theorem variants that the newly declared environment will call @@ -631,7 +641,7 @@ % \end{syntax} % % This behaves essentially the same as \cs{NewGroupedTheoremFamilyOptions}, -% but also declares the environment \meta{theorem name*}, +% but also declares the environment \mymeta{theorem name*}, % which behaves the same but calls the theorem variants with the additional \kw{starred} % subgroup. % @@ -651,7 +661,7 @@ % \end{syntax} % % Combines the behavior of \cs{NewGroupedTheoremFamilyOptions*} and \cs{NewTheoremFamilyOptions}, -% thus declaring both \meta{theorem name} and \meta{theorem name*} environments, +% thus declaring both \mymeta{theorem name} and \mymeta{theorem name*} environments, % the latter calling the \kw{starred} variants of the theorem family, % and both of them calling \kw{unnumbered} variants of the family. % @@ -686,14 +696,14 @@ % 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 +% \item \cs{groupthm_new_foo:mmm}\mymeta{mandatory args}\mymeta{optional args}, +% where the \mymeta{mandatory args} list the mandatory args of the \LaTeX2e +% interface, and the \mymeta{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}\marg{keys}\meta{mandatory args} +% \item \cs{groupthm_new_foo_from_keys:mmm}\marg{keys}\mymeta{mandatory args} % where we pass a \texttt{clist} as the first argument and all mandatory args % as further mandatory arguments. -% \item \cs{NewFoo}\oarg{keys}\meta{mandatory args}, +% \item \cs{NewFoo}\oarg{keys}\mymeta{mandatory args}, % where the keys can be passed optionally. % \end{itemize} % @@ -952,7 +962,7 @@ % % \begin{macro}{\@@_thmtools_declare_theorem:nn, \@@_thmtools_declare_theorem:Vn} % \begin{syntax} -% \cs{@@_thmtools_declare_theorem:nn} \meta{theorem name}\meta{thmtools keyval args} +% \cs{@@_thmtools_declare_theorem:nn} \mymeta{theorem name}\mymeta{thmtools keyval args} % \end{syntax} % % This is just a private wrapper around \cs{declaretheorem} of the \pkg{thmtools} package. @@ -973,7 +983,7 @@ % hook role setting mechanism: % \begin{macro}{\@@_hook_gset_rule_foreach:nNnn} % \begin{syntax} -% \cs{@@_hook_gset_rule_foreach:nNnn}\marg{hook}\meta{clist name}\meta{relation}\meta{label} +% \cs{@@_hook_gset_rule_foreach:nNnn}\marg{hook}\mymeta{clist name}\mymeta{relation}\mymeta{label} % \end{syntax} % % This is a wrapper around the \cs{hook_gset_rule:nnnn} macro @@ -1209,7 +1219,7 @@ % 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}. +% \mymeta{fallback name}. % % \begin{macrocode} \cs_new:Npn \@@_set_normalized_keys:nnn #1 #2 #3 @@ -1353,9 +1363,9 @@ % \end{macro} % % -% \begin{macro}{\@@_declare_theorem_group_aux:nnnnn} +% \begin{macro}{\@@_define_group_aux:nnnnn} % \begin{syntax} -% \cs{@@_declare_theorem_group_aux:nnnnn}\marg{theorem group}\marg{prefix tl} +% \cs{@@_define_group_aux:nnnnn}\marg{theorem group}\marg{prefix tl} % \marg{suffix tl}\marg{mapname clist}\marg{thmtools clist} % \end{syntax} % @@ -1368,11 +1378,11 @@ % % % \begin{macrocode} -\cs_new:Npn \@@_declare_theorem_group_aux:nnnnn #1#2#3#4#5 +\cs_new:Npn \@@_define_group_aux:nnnnn #1#2#3#4#5 { % \end{macrocode} % -% \begin{macro}{\@@_use_group_#:} +% \begin{macro}{\@@_use_group_\meta{theorem 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. @@ -1415,9 +1425,9 @@ % \end{macro} % % -% \begin{macro}{\@@_undeclare_theorem_group_aux:n} +% \begin{macro}{\@@_undefine_group_aux:n} % \begin{syntax} -% \cs{@@_undeclare_theorem_group_aux:n}\marg{theorem group} +% \cs{@@_undefine_group_aux:n}\marg{theorem group} % \end{syntax} % % Undeclares / undefines the given theorem group. @@ -1429,7 +1439,7 @@ % This macro assumes that the group was defined prior to calling. % % \begin{macrocode} -\cs_new:Npn \@@_undeclare_theorem_group_aux:n #1 +\cs_new:Npn \@@_undefine_group_aux:n #1 { \cs_undefine:c { @@_use_group_#1: } % \end{macrocode} @@ -1494,17 +1504,59 @@ % \begin{macro}{\groupthm_new_theorem_group:nnnnn, \groupthm_new_theorem_group:nVVVV} % % \begin{macrocode} +\cs_new:Npn \@@_define_aux:nnnNNNn #1 #2 #3 #4 #5 #6 #7 +{ + \bool_if:nT + { + \str_if_eq_p:nn { #1 } { new } + && + \cs_if_exist_p:N #4 + } + { + \msg_error:nnnn { groupthm } { wrong ~ definition } + { #2 } { #3 } { already } + } + + \bool_if:nT + { + \str_if_eq_p:nn { #1 } { renew } + && + ! \cs_if_exist_p:N #4 + } + { + \msg_error:nnnn { groupthm } { wrong ~ definition } + { #2 } { #3 } { not } + } + + \bool_if:nT + { + ( + \str_if_eq_p:nn { #1 } { declare } || + \str_if_eq_p:nn { #1 } { renew } + ) && + \cs_if_exist_p:N #4 + } + { + #5 { #1 } + } + + #6 #7 +} +\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_if_exist:cTF { @@_use_group_#1: } - { - \msg_error:nnnnn { groupthm } { wrong ~ definition } - { theorem ~ group } { #1 } { already } - } - { - \@@_declare_theorem_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 } - } - } +{ + \@@_define_aux:nnncNNn + { new } + { theorem group } + { #1 } + { @@_use_group_#1: } + \@@_undefine_group_aux:n + \@@_define_group_aux:nnnnn + { + { #1 } { #2 } { #3 } { #4 } { #5 } + } +} % \end{macrocode} % % Finally, generate some extra variant. @@ -1523,8 +1575,8 @@ { \cs_if_exist:cTF { @@_use_group_#1: } { - \@@_undeclare_theorem_group_aux:n { #1 } - \@@_declare_theorem_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 } + \@@_undefine_group_aux:n { #1 } + \@@_define_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 } } { \msg_error:nnnnn { groupthm } { wrong ~ definition } @@ -1549,7 +1601,7 @@ { \cs_if_exist:cF { @@_use_group_#1: } { - \@@_declare_theorem_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 } + \@@_define_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 } } } % \end{macrocode} @@ -1571,9 +1623,9 @@ { \cs_if_exist:cT { @@_use_group_#1: } { - \@@_undeclare_theorem_group_aux:n { #1 } + \@@_undefine_group_aux:n { #1 } } - \@@_declare_theorem_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 } + \@@_define_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 } } % \end{macrocode} % @@ -1727,7 +1779,7 @@ % % We have to normalize the arguments a little bit, namely replacing \texttt{higher} % and \texttt{lower} with \texttt{before} \texttt{after} respectively, -% and prefix the \meta{keyname} with \texttt{__groupthm} +% and prefix the \mymeta{keyname} with \texttt{__groupthm} % in case it is not the general hook \enquote{\texttt{??}}. % % \begin{macrocode} @@ -1779,12 +1831,12 @@ % % \begin{macro}{\@@_powerset_clist_foreach:Nn} % \begin{syntax} -% \cs{@@_powerset_clist_foreach:Nn}\meta{clist}\marg{code} +% \cs{@@_powerset_clist_foreach:Nn}\mymeta{clist}\marg{code} % \end{syntax} % -% Executes \meta{code} for each subset of the given clist variable. +% Executes \mymeta{code} for each subset of the given clist variable. % The value of the (local) variable is changes throughout the iteration, -% and is thus available regularly in \meta{code}. +% and is thus available regularly in \mymeta{code}. % Its value is restored at the end of the iteration. % % \begin{macrocode} @@ -1834,7 +1886,7 @@ % % \begin{macro}{\@@_use_theorem_group:n} % \begin{syntax} -% \cs{@@_use_theorem_group:n}\meta{theorem group} +% \cs{@@_use_theorem_group:n}\mymeta{theorem group} % \end{syntax} % % Uses this theorem group, i.e.~applies its definition by writing @@ -1856,10 +1908,10 @@ % % \begin{macro}{\@@_use_function_on_name:n} % \begin{syntax} -% \cs{@@_use_function_on_name:n}\meta{function} +% \cs{@@_use_function_on_name:n}\mymeta{function} % \end{syntax} % -% The \meta{function} is expected to be of type \texttt{:n}, +% The \mymeta{function} is expected to be of type \texttt{:n}, % This applies the function to the \cs{l_@@_name_tl} % % \begin{macrocode} @@ -2364,20 +2416,20 @@ % \marg{name}\marg{name}\marg{thmtools clist}\marg{extra groups clist}\marg{generation type} % \end{syntax} % -% This will generate a new grouped theorem for each union of a subset of \meta{groups clist} -% and the extra set \meta{extra groups clist}, with the given properties, that is -% the \meta{nam} and \meta{thmtools clist} will be passed to the grouped theorem. -% The \meta{theorem name} of the grouped theorem will be an internal name that contains -% the \meta{family name} and the list of groups of this variant, that will be generated +% This will generate a new grouped theorem for each union of a subset of \mymeta{groups clist} +% and the extra set \mymeta{extra groups clist}, with the given properties, that is +% the \mymeta{nam} and \mymeta{thmtools clist} will be passed to the grouped theorem. +% The \mymeta{theorem name} of the grouped theorem will be an internal name that contains +% the \mymeta{family name} and the list of groups of this variant, that will be generated % in a unique manner to later retrieve the generated theorems when parsing theorem families. % -% The \meta{generation type} can be either \texttt{new} or \texttt{provide}, +% The \mymeta{generation type} can be either \texttt{new} or \texttt{provide}, % depending on which backend for grouped theorem generation to use % \begin{macrocode} \cs_new:Npn \@@_declare_grouped_theorem_family_aux:nnnnnn #1 #2 #3 #4 #5 #6 { % \end{macrocode} -% Make a local copy of the \meta{groups clist} argument, +% Make a local copy of the \mymeta{groups clist} argument, % and iterate over its powerset % \begin{macrocode} \clist_set:Nn \l_tmpa_clist { #2 } @@ -2863,7 +2915,7 @@ { % \end{macrocode} % As mentioned earlier, this bool will indicate whether we are -% executing a \meta{selection body} from some family options. +% executing a \mymeta{selection body} from some family options. % If used outside, we emit an error message. % \begin{macrocode} \bool_if:NTF \l_@@_in_family_options_environment_bool @@ -2902,12 +2954,12 @@ % \end{syntax} % % This declares a new theorem variant option parser, i.e.~ introduces the environment -% \meta{theorem family} with signature \marg{argument specification}. +% \mymeta{theorem family} with signature \marg{argument specification}. % -% The \meta{selection body} will be executed and selects some groups the environment shall have. -% The \meta{extra groups} will be added regardless of the arguments given -% to the \meta{theorem family} -% The \meta{declaring backend} is one of \texttt{New}, \texttt{Renew}, \texttt{Provide} +% The \mymeta{selection body} will be executed and selects some groups the environment shall have. +% The \mymeta{extra groups} will be added regardless of the arguments given +% to the \mymeta{theorem family} +% The \mymeta{declaring backend} is one of \texttt{New}, \texttt{Renew}, \texttt{Provide} % and \texttt{Declare} and is given to the \texttt{DocumentEnvironment} command from \pkg{xpars}. % % \begin{macrocode} @@ -2918,7 +2970,7 @@ { #2 } { % \end{macrocode} -% We can now clear the group list and execute the \meta{selection body} +% We can now clear the group list and execute the \mymeta{selection body} % that populates this list again. % Additionally, we add the groups that should always be present and activate the % \cs{AddTheoremToGroup} macro by setting the bool. @@ -2965,7 +3017,7 @@ % % % All other macros are now essentially wrappers around this aux macro, -% passing different \meta{extra groups} to them +% passing different \mymeta{extra groups} to them % % \begin{macro}{\groupthm_new_grouped_theorem_family_options:nnn} % \begin{syntax} @@ -3372,6 +3424,10 @@ % % % -% +% \ExplSyntaxOn +% \__codedoc_special_index_module:nnnnN { key } { macro } { module } { main } { \c_false_bool} +% \__codedoc_special_index_module:nnnnN { l } { bla } { module } { usage } { \c_false_bool} +% \ExplSyntaxOff % % \newpage +% \PrintIndex diff --git a/doc/environments/groupthm/groupthm.sty b/doc/environments/groupthm/groupthm.sty index 4ebf4b0..1402d99 100644 --- a/doc/environments/groupthm/groupthm.sty +++ b/doc/environments/groupthm/groupthm.sty @@ -66,21 +66,21 @@ Probably ~ you ~ forgot ~ this. ~ \msg_see_documentation_text:n { groupthm } } -\hook_new:n { __groupthm/prename } -\hook_new:n { __groupthm/postname } +\hook_new:n { __groupthm/prefix } +\hook_new:n { __groupthm/suffix } \hook_new:n { __groupthm/mapname } \hook_new:n { __groupthm/thmtools } \hook_new:n { __groupthm/groupsort } \cs_generate_variant:Nn \hook_gset_rule:nnnn { n n V n } -\tl_new:N \l__groupthm_key_prename_tl +\tl_new:N \l__groupthm_key_prefix_tl \tl_new:N \l__groupthm_key_name_tl -\tl_new:N \l__groupthm_key_postname_tl +\tl_new:N \l__groupthm_key_suffix_tl \clist_new:N \l__groupthm_key_group_clist \clist_new:N \l__groupthm_key_mapname_clist \clist_new:N \l__groupthm_key_thmtools_clist -\tl_new:N \l__groupthm_prename_tl +\tl_new:N \l__groupthm_prefix_tl \tl_new:N \l__groupthm_name_tl -\tl_new:N \l__groupthm_postname_tl +\tl_new:N \l__groupthm_suffix_tl \clist_new:N \l__groupthm_mapname_clist \clist_new:N \l__groupthm_thmtools_clist \clist_new:N \l__groupthm_group_clist @@ -88,15 +88,15 @@ \bool_new:N \l__groupthm_in_family_options_environment_bool \keys_define:nn { groupthm } { - prename .tl_set:N = \l__groupthm_key_prename_tl, - prename .default:n = \c_empty_tl, - prename .groups:n = { theoremgroup }, + prefix .tl_set:N = \l__groupthm_key_prefix_tl, + prefix .default:n = \c_empty_tl, + prefix .groups:n = { theoremgroup }, name .tl_set:N = \l__groupthm_key_name_tl, name .default:n = \c_novalue_tl, name .groups:n = { groupedtheorem, theoremvariants }, - postname .tl_set:N = \l__groupthm_key_postname_tl, - postname .default:n = \c_empty_tl, - postname .groups:n = { theoremgroup }, + suffix .tl_set:N = \l__groupthm_key_suffix_tl, + suffix .default:n = \c_empty_tl, + suffix .groups:n = { theoremgroup }, group .clist_set:N = \l__groupthm_key_group_clist, group .default:n = {}, group .groups:n = { groupedtheorem, theoremvariants }, @@ -112,7 +112,7 @@ } \cs_new:Npn \__groupthm_set_normalized_keys:nnn #1 #2 #3 { - \keys_set:nn { groupthm } { prename, name, postname, group, mapname, thmtools } + \keys_set:nn { groupthm } { prefix, name, suffix, group, mapname, thmtools } \keys_set_groups:nnn { groupthm } { #2 } { #1 } \tl_if_eq:NnTF \l__groupthm_key_name_tl { \c_novalue_tl } { @@ -124,8 +124,8 @@ { \tl_set_eq:NN \l__groupthm_name_tl \l__groupthm_key_name_tl } - \tl_set_eq:NN \l__groupthm_prename_tl \l__groupthm_key_prename_tl - \tl_set_eq:NN \l__groupthm_postname_tl \l__groupthm_key_postname_tl + \tl_set_eq:NN \l__groupthm_prefix_tl \l__groupthm_key_prefix_tl + \tl_set_eq:NN \l__groupthm_suffix_tl \l__groupthm_key_suffix_tl \clist_set_eq:NN \l__groupthm_group_clist \l__groupthm_key_group_clist \clist_set_eq:NN \l__groupthm_mapname_clist \l__groupthm_key_mapname_clist \clist_set_eq:NN \l__groupthm_thmtools_clist \l__groupthm_key_thmtools_clist @@ -161,17 +161,17 @@ \clist_clear:N \l__groupthm_group_clist \hook_use:n { __groupthm/groupsort } } -\cs_new:Npn \__groupthm_declare_theorem_group_aux:nnnnn #1#2#3#4#5 +\cs_new:Npn \__groupthm_define_group_aux:nnnnn #1#2#3#4#5 { \cs_new:cpn { __groupthm_use_group_#1: } { - \hook_gput_code:nnn { __groupthm/prename } { #1 } + \hook_gput_code:nnn { __groupthm/prefix } { #1 } { - \tl_put_left:Nx \l__groupthm_prename_tl { #2 } + \tl_put_left:Nx \l__groupthm_prefix_tl { #2 } } - \hook_gput_code:nnn { __groupthm/postname } { #1 } + \hook_gput_code:nnn { __groupthm/suffix } { #1 } { - \tl_put_right:Nx \l__groupthm_postname_tl { #3 } + \tl_put_right:Nx \l__groupthm_suffix_tl { #3 } } \hook_gput_code:nnn { __groupthm/mapname } { #1 } { @@ -185,11 +185,11 @@ \__groupthm_add_to_theorem_group_ordering:n { #1 } \clist_gput_left:Nn \g__groupthm_defined_theorem_groups_clist { #1 } } -\cs_new:Npn \__groupthm_undeclare_theorem_group_aux:n #1 +\cs_new:Npn \__groupthm_undefine_group_aux:n #1 { \cs_undefine:c { __groupthm_use_group_#1: } - \hook_gremove_code:nn { __groupthm/prename } { #1 } - \hook_gremove_code:nn { __groupthm/postname } { #1 } + \hook_gremove_code:nn { __groupthm/prefix } { #1 } + \hook_gremove_code:nn { __groupthm/suffix } { #1 } \hook_gremove_code:nn { __groupthm/mapname } { #1 } \hook_gremove_code:nn { __groupthm/thmtools } { #1 } \clist_gremove_all:Nn \g__groupthm_defined_theorem_groups_clist { #1 } @@ -199,12 +199,12 @@ { unrelated } { #1 } \__groupthm_hook_gset_rule_foreach:nNnn - { __groupthm/prename } + { __groupthm/prefix } \g__groupthm_defined_theorem_groups_clist { unrelated } { #1 } \__groupthm_hook_gset_rule_foreach:nNnn - { __groupthm/postname } + { __groupthm/suffix } \g__groupthm_defined_theorem_groups_clist { unrelated } { #1 } @@ -220,24 +220,66 @@ { #1 } \__groupthm_remove_from_theorem_group_ordering:n { #1 } } +\cs_new:Npn \__groupthm_define_aux:nnnNNNn #1 #2 #3 #4 #5 #6 #7 +{ + \bool_if:nT + { + \str_if_eq_p:nn { #1 } { new } + && + \cs_if_exist_p:N #4 + } + { + \msg_error:nnnn { groupthm } { wrong ~ definition } + { #2 } { #3 } { already } + } + + \bool_if:nT + { + \str_if_eq_p:nn { #1 } { renew } + && + ! \cs_if_exist_p:N #4 + } + { + \msg_error:nnnn { groupthm } { wrong ~ definition } + { #2 } { #3 } { not } + } + + \bool_if:nT + { + ( + \str_if_eq_p:nn { #1 } { declare } || + \str_if_eq_p:nn { #1 } { renew } + ) && + \cs_if_exist_p:N #4 + } + { + #5 { #1 } + } + + #6 #7 +} +\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_if_exist:cTF { __groupthm_use_group_#1: } - { - \msg_error:nnnnn { groupthm } { wrong ~ definition } - { theorem ~ group } { #1 } { already } - } - { - \__groupthm_declare_theorem_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 } - } - } +{ + \__groupthm_define_aux:nnncNNn + { new } + { theorem group } + { #1 } + { __groupthm_use_group_#1: } + \__groupthm_undefine_group_aux:n + \__groupthm_define_group_aux:nnnnn + { + { #1 } { #2 } { #3 } { #4 } { #5 } + } +} \cs_generate_variant:Nn \groupthm_new_theorem_group:nnnnn { n V V V V } \cs_new:Npn \groupthm_renew_theorem_group:nnnnn #1 #2 #3 #4 #5 { \cs_if_exist:cTF { __groupthm_use_group_#1: } { - \__groupthm_undeclare_theorem_group_aux:n { #1 } - \__groupthm_declare_theorem_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 } + \__groupthm_undefine_group_aux:n { #1 } + \__groupthm_define_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 } } { \msg_error:nnnnn { groupthm } { wrong ~ definition } @@ -249,7 +291,7 @@ { \cs_if_exist:cF { __groupthm_use_group_#1: } { - \__groupthm_declare_theorem_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 } + \__groupthm_define_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 } } } \cs_generate_variant:Nn \groupthm_provide_theorem_group:nnnnn { n V V V V } @@ -257,17 +299,17 @@ { \cs_if_exist:cT { __groupthm_use_group_#1: } { - \__groupthm_undeclare_theorem_group_aux:n { #1 } + \__groupthm_undefine_group_aux:n { #1 } } - \__groupthm_declare_theorem_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 } + \__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_new_theorem_group:nVVVV { #2 } - \l__groupthm_prename_tl - \l__groupthm_postname_tl + \l__groupthm_prefix_tl + \l__groupthm_suffix_tl \l__groupthm_mapname_clist \l__groupthm_thmtools_clist } @@ -275,8 +317,8 @@ { \__groupthm_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 } \groupthm_renew_theorem_group:nVVVV { #2 } - \l__groupthm_prename_tl - \l__groupthm_postname_tl + \l__groupthm_prefix_tl + \l__groupthm_suffix_tl \l__groupthm_mapname_clist \l__groupthm_thmtools_clist } @@ -284,8 +326,8 @@ { \__groupthm_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 } \groupthm_provide_theorem_group:nVVVV { #2 } - \l__groupthm_prename_tl - \l__groupthm_postname_tl + \l__groupthm_prefix_tl + \l__groupthm_suffix_tl \l__groupthm_mapname_clist \l__groupthm_thmtools_clist } @@ -293,8 +335,8 @@ { \__groupthm_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 } \groupthm_declare_theorem_group:nVVVV { #2 } - \l__groupthm_prename_tl - \l__groupthm_postname_tl + \l__groupthm_prefix_tl + \l__groupthm_suffix_tl \l__groupthm_mapname_clist \l__groupthm_thmtools_clist } @@ -393,26 +435,26 @@ } \cs_new:Npn \__groupthm_declare_grouped_theorem_aux:nnnn #1 #2 #3 #4 { - \tl_clear:N \l__groupthm_prename_tl + \tl_clear:N \l__groupthm_prefix_tl \tl_set:Nn \l__groupthm_name_tl { #3 } - \tl_clear:N \l__groupthm_postname_tl + \tl_clear:N \l__groupthm_suffix_tl \clist_clear:N \l__groupthm_mapname_clist \clist_clear:N \l__groupthm_thmtools_clist - \hook_gremove_code:nn { __groupthm/prename }{*} - \hook_gremove_code:nn { __groupthm/postname }{*} + \hook_gremove_code:nn { __groupthm/prefix }{*} + \hook_gremove_code:nn { __groupthm/suffix }{*} \hook_gremove_code:nn { __groupthm/mapname }{*} \hook_gremove_code:nn { __groupthm/thmtools }{*} \clist_map_function:nN { #2 } \__groupthm_use_theorem_group:n - \hook_use:n { __groupthm/prename } - \hook_use:n { __groupthm/postname } + \hook_use:n { __groupthm/prefix } + \hook_use:n { __groupthm/suffix } \hook_use:n { __groupthm/mapname } \hook_use:n { __groupthm/thmtools } \clist_map_function:NN \l__groupthm_mapname_clist \map_use_on_name:n \clist_put_right:Nx \l__groupthm_thmtools_clist { - name = \tl_use:N \l__groupthm_prename_tl + name = \tl_use:N \l__groupthm_prefix_tl \tl_use:N \l__groupthm_name_tl - \tl_use:N \l__groupthm_postname_tl + \tl_use:N \l__groupthm_suffix_tl } \clist_put_right:Nn \l__groupthm_thmtools_clist { #4 } \__groupthm_thmtools_declare_theorem:Vn