diff --git a/doc/environments/groupthm/groupthm.dtx b/doc/environments/groupthm/groupthm.dtx index dc8f6ae..3cdc246 100644 --- a/doc/environments/groupthm/groupthm.dtx +++ b/doc/environments/groupthm/groupthm.dtx @@ -813,7 +813,8 @@ % \groupthm_provide_theorem_star:nnnn % } % \begin{syntax} -% \cs{groupthm_new_theorem:nnnn}\marg{keys}\marg{environment name} +% \cs{groupthm_new_theorem:nnnn}\marg{environment name}\marg{groups clist} +% \marg{theorem name}\marg{thmtools keys} % \end{syntax} % % Non-keyval versions of above macros. @@ -2196,6 +2197,505 @@ % % % +% \subsection{Theorem families} +% +% +% We now want to implement the generation of theorem families and their +% corresponding options. +% As a backend, we use the following auxiliary function +% +% +% \begin{macro}{\@@_declare_grouped_theorem_family_aux:nnnnnn} +% \begin{syntax} +% \cs{@@_declare_grouped_theorem_family_aux:nnnnnn}\marg{family name}\marg{groups clist} +% \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 +% 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}, +% depending on which backend for grouped theorem generation to use +% \begin{macrocode} +\cs_new:Npn \@@_declare_grouped_theorem_family_aux:nnnnnn + { +% \end{macrocode} +% Make a local copy of the \meta{groups clist} argument, +% and iterate over its powerset +% \begin{macrocode} + \clist_set:Nn \l_tmpa_clist { #2 } + \powerset_clist_foreach:Nn \l_tmpa_clist + { +% \end{macrocode} +% We read out the current value of the list, and append the extra groups +% This ensures that now \cs{l_@@_group_clist} iterates over the proper subsets +% \begin{macrocode} + \clist_set_eq:NN \l_@@_group_clist \l_tmpa_clist + \clist_put_right:Nn \l_@@_group_clist { #5 } +% \end{macrocode} +% This sorting is necessary so that for each theorem family and set of groups, +% the generated name will be unique: +% \begin{macrocode} + \__sort_group_names: +% \end{macrocode} +% Now just declare the grouped theorem, passing the corresponding arguments and using +% specified \texttt{\#6} as backend. +% \begin{macrocode} + \use:c{groupthm_#6_grouped_theorem:xVnn} + {__#1__groups_\clist_use:Nn \l_@@_group_clist {_}} + \l_@@_group_clist + { #3 } + { #4 } + } + } +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\groupthm_new_grouped_theorem_family:nnnn,\groupthm_new_grouped_theorem_family:nVVV} +% \begin{syntax} +% \cs{groupthm_new_grouped_theorem_family:nnnn}\marg{family name} +% \marg{groups}\marg{name}\marg{thmtools clist} +% \end{syntax} +% +% Just pass the arguments to the auxiliary function, with no additional groups +% and the \texttt{new} backend. +% +% \begin{macrocode} +\cs_new:Npn \groupthm_new_grouped_theorem_family:nnnn #1 #2 #3 #4 + { + \@@_declare_grouped_theorem_family_aux:nnnnnn + { #1 } { #2 } { #3 } { #4 } { } { new } + } +\cs_generate_variant:Nn \groupthm_new_grouped_theorem_family:nnnn { n V V V } +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\groupthm_provide_grouped_theorem_family:nnnn,\groupthm_provide_grouped_theorem_family:nVVV} +% \begin{syntax} +% \cs{groupthm_provide_grouped_theorem_family:nnnn}\marg{family name} +% \marg{groups}\marg{name}\marg{thmtools clist} +% \end{syntax} +% +% Just pass the arguments to the auxiliary function, with no additional groups +% and the \texttt{provide} backend. +% +% \begin{macrocode} +\cs_new:Npn \groupthm_provide_grouped_theorem_family:nnnn #1 #2 #3 #4 + { + \@@_declare_grouped_theorem_family_aux:nnnnnn + { #1 } { #2 } { #3 } { #4 } { } { provide } + } +\cs_generate_variant:Nn \groupthm_provide_grouped_theorem_family:nnnn { n V V V } +% \end{macrocode} +% \end{macro} +% +% +% The starred variants that add the \texttt{unnumbered} group are straightforward: +% +% +% +% \begin{macro}{\groupthm_new_grouped_theorem_family_star:nnnn,\groupthm_new_grouped_theorem_family_star:nVVV} +% \begin{syntax} +% \cs{groupthm_new_grouped_theorem_family_star:nnnn}\marg{family name} +% \marg{groups}\marg{name}\marg{thmtools clist} +% \end{syntax} +% +% Just pass the arguments to the auxiliary function, with the additional +% \texttt{unnumbered group} and the \texttt{new} backend. +% +% \begin{macrocode} +\cs_new:Npn \groupthm_new_grouped_theorem_family_star:nnnn #1 #2 #3 #4 + { + \@@_declare_grouped_theorem_family_aux:nnnnnn + { #1 } { #2 } { #3 } { #4 } { unnumbered } { new } + } +\cs_generate_variant:Nn \groupthm_new_grouped_theorem_family_star:nnnn { n V V V } +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\groupthm_provide_grouped_theorem_family_star:nnnn,\groupthm_provide_grouped_theorem_family_star:nVVV} +% \begin{syntax} +% \cs{groupthm_provide_grouped_theorem_family_star:nnnn}\marg{family name} +% \marg{groups}\marg{name}\marg{thmtools clist} +% \end{syntax} +% +% Just pass the arguments to the auxiliary function, with the additional +% \texttt{unnumbered group} and the \texttt{provide} backend. +% +% \begin{macrocode} +\cs_new:Npn \groupthm_provide_grouped_theorem_family_star:nnnn #1 #2 #3 #4 + { + \@@_declare_grouped_theorem_family_aux:nnnnnn + { #1 } { #2 } { #3 } { #4 } { } { provide } + } +\cs_generate_variant:Nn \groupthm_provide_grouped_theorem_family_star:nnnn { n V V V } +% \end{macrocode} +% \end{macro} +% +% +% Now define the variants that also generate the starred and unstarred family versions. +% +% +% \begin{macro}{\groupthm_new_theorem_family:nnnn,\groupthm_new_theorem_family:nVVV} +% \begin{syntax} +% \cs{groupthm_new_theorem_family:nnnn}\marg{family name} +% \marg{groups}\marg{name}\marg{thmtools clist} +% \end{syntax} +% +% +% \begin{macrocode} +\cs_new:Npn \groupthm_new_theorem_family:nnnn #1 #2 #3 #4 + { + \@@_declare_grouped_theorem_family_aux:nnnnnn + { #1 } { #2, starred } { #3 } { #4 } { } { new } + } +\cs_generate_variant:Nn \groupthm_new_theorem_family:nnnn { n V V V } +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\groupthm_provide_theorem_family:nnnn,\groupthm_provide_theorem_family:nVVV} +% \begin{syntax} +% \cs{groupthm_provide_theorem_family:nnnn}\marg{family name} +% \marg{groups}\marg{name}\marg{thmtools clist} +% \end{syntax} +% +% +% \begin{macrocode} +\cs_new:Npn \groupthm_provide_theorem_family:nnnn #1 #2 #3 #4 + { + \@@_declare_grouped_theorem_family_aux:nnnnnn + { #1 } { #2, starred } { #3 } { #4 } { } { provide } + } +\cs_generate_variant:Nn \groupthm_provide_theorem_family:nnnn { n V V V } +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\groupthm_new_theorem_family_star:nnnn,\groupthm_new_theorem_family_star:nVVV} +% \begin{syntax} +% \cs{groupthm_new_theorem_family_star:nnnn}\marg{family name} +% \marg{groups}\marg{name}\marg{thmtools clist} +% \end{syntax} +% +% +% \begin{macrocode} +\cs_new:Npn \groupthm_new_theorem_family_star:nnnn #1 #2 #3 #4 + { + \@@_declare_grouped_theorem_family_aux:nnnnnn + { #1 } { #2, starred } { #3 } { #4 } { unnumbered } { new } + } +\cs_generate_variant:Nn \groupthm_new_theorem_family_star:nnnn { n V V V } +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\groupthm_provide_theorem_family_star:nnnn,\groupthm_provide_theorem_family_star:nVVV} +% \begin{syntax} +% \cs{groupthm_provide_theorem_family_star:nnnn}\marg{family name} +% \marg{groups}\marg{name}\marg{thmtools clist} +% \end{syntax} +% +% +% \begin{macrocode} +\cs_new:Npn \groupthm_provide_theorem_family_star:nnnn #1 #2 #3 #4 + { + \@@_declare_grouped_theorem_family_aux:nnnnnn + { #1 } { #2, starred } { #3 } { #4 } { } { provide } + } +\cs_generate_variant:Nn \groupthm_provide_theorem_family_star:nnnn { n V V V } +% \end{macrocode} +% \end{macro} +% +% +% +% We now make the key variants available of these, all of the work in the same way +% as we just have to set the normalized keys and pass to our non-key-value versions. +% +% +% +% +% \begin{macro}{\groupthm_new_grouped_theorem_family_from_keys:nn} +% \begin{syntax} +% \cs{groupthm_new_grouped_theorem_family_from_keys:nn}\marg{keys}\marg{family name} +% \end{syntax} +% +% Just retrieve the normalized keys and pass on arguments. +% +% \begin{macrocode} +\cs_new:Npn \groupthm_new_grouped_theorem_family_from_keys:nn #1 #2 + { + \@@_set_normalized_keys:nn { #1 } { #2 } + \groupthm_new_grouped_theorem_family:nVVV + { #2 } + \l_@@_groups_clist + \l_@@_name_tl + \l_@@_thmtools_clist + } +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\groupthm_provide_grouped_theorem_family_from_keys:nn} +% \begin{syntax} +% \cs{groupthm_provide_grouped_theorem_family_from_keys:nn}\marg{keys}\marg{family name} +% \end{syntax} +% +% Just retrieve the normalized keys and pass on arguments. +% +% \begin{macrocode} +\cs_new:Npn \groupthm_provide_grouped_theorem_family_from_keys:nn #1 #2 + { + \@@_set_normalized_keys:nn { #1 } { #2 } + \groupthm_provide_grouped_theorem_family:nVVV + { #2 } + \l_@@_groups_clist + \l_@@_name_tl + \l_@@_thmtools_clist + } +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\groupthm_new_grouped_theorem_family_star_from_keys:nn} +% \begin{syntax} +% \cs{groupthm_new_grouped_theorem_family_star_from_keys:nn}\marg{keys}\marg{family name} +% \end{syntax} +% +% Just retrieve the normalized keys and pass on arguments. +% +% \begin{macrocode} +\cs_new:Npn \groupthm_new_grouped_theorem_family_star_from_keys:nn #1 #2 + { + \@@_set_normalized_keys:nn { #1 } { #2 } + \groupthm_new_grouped_theorem_family_star:nVVV + { #2 } + \l_@@_groups_clist + \l_@@_name_tl + \l_@@_thmtools_clist + } +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\groupthm_provide_grouped_theorem_family_star_from_keys:nn} +% \begin{syntax} +% \cs{groupthm_provide_grouped_theorem_family_star_from_keys:nn}\marg{keys}\marg{family name} +% \end{syntax} +% +% Just retrieve the normalized keys and pass on arguments. +% +% \begin{macrocode} +\cs_new:Npn \groupthm_provide_grouped_theorem_family_star_from_keys:nn #1 #2 + { + \@@_set_normalized_keys:nn { #1 } { #2 } + \groupthm_provide_grouped_theorem_family_star:nVVV + { #2 } + \l_@@_groups_clist + \l_@@_name_tl + \l_@@_thmtools_clist + } +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\groupthm_new_theorem_family_from_keys:nn} +% \begin{syntax} +% \cs{groupthm_new_theorem_family_from_keys:nn}\marg{keys}\marg{family name} +% \end{syntax} +% +% Just retrieve the normalized keys and pass on arguments. +% +% \begin{macrocode} +\cs_new:Npn \groupthm_new_theorem_family_from_keys:nn #1 #2 + { + \@@_set_normalized_keys:nn { #1 } { #2 } + \groupthm_new_theorem_family:nVVV + { #2 } + \l_@@_groups_clist + \l_@@_name_tl + \l_@@_thmtools_clist + } +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\groupthm_provide_theorem_family_from_keys:nn} +% \begin{syntax} +% \cs{groupthm_provide_theorem_family_from_keys:nn}\marg{keys}\marg{family name} +% \end{syntax} +% +% Just retrieve the normalized keys and pass on arguments. +% +% \begin{macrocode} +\cs_new:Npn \groupthm_provide_theorem_family_from_keys:nn #1 #2 + { + \@@_set_normalized_keys:nn { #1 } { #2 } + \groupthm_provide_theorem_family:nVVV + { #2 } + \l_@@_groups_clist + \l_@@_name_tl + \l_@@_thmtools_clist + } +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\groupthm_new_theorem_family_star_from_keys:nn} +% \begin{syntax} +% \cs{groupthm_new_theorem_family_star_from_keys:nn}\marg{keys}\marg{family name} +% \end{syntax} +% +% Just retrieve the normalized keys and pass on arguments. +% +% \begin{macrocode} +\cs_new:Npn \groupthm_new_theorem_family_star_from_keys:nn #1 #2 + { + \@@_set_normalized_keys:nn { #1 } { #2 } + \groupthm_new_theorem_family_star:nVVV + { #2 } + \l_@@_groups_clist + \l_@@_name_tl + \l_@@_thmtools_clist + } +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\groupthm_provide_theorem_family_star_from_keys:nn} +% \begin{syntax} +% \cs{groupthm_provide_theorem_family_star_from_keys:nn}\marg{keys}\marg{family name} +% \end{syntax} +% +% Just retrieve the normalized keys and pass on arguments. +% +% \begin{macrocode} +\cs_new:Npn \groupthm_provide_theorem_family_star_from_keys:nn #1 #2 + { + \@@_set_normalized_keys:nn { #1 } { #2 } + \groupthm_provide_theorem_family_star:nVVV + { #2 } + \l_@@_groups_clist + \l_@@_name_tl + \l_@@_thmtools_clist + } +% \end{macrocode} +% \end{macro} +% +% +% +% Finally, we can provide document commands that make these available. +% +% +% \begin{macro}{\NewGroupedTheoremFamily,\NewGroupedTheoremFamily*} +% \begin{syntax} +% \cs{NewGroupedTheoremFamily}\oarg{keys}\marg{family name} +% \end{syntax} +% +% +% +% \begin{macrocode} +\NewDocumentCommand{\NewGroupedTheoremFamily}{s O{} m} + { + \IfBooleanTF { #1 } + { + \groupthm_new_grouped_theorem_family_from_keys:nn { #2 } { #3 } + } + { + \groupthm_new_grouped_theorem_family_star_from_keys:nn { #2 } { #3 } + } + } +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\ProvideGroupedTheoremFamily,\ProvideGroupedTheoremFamily*} +% \begin{syntax} +% \cs{ProvideGroupedTheoremFamily}\oarg{keys}\marg{family name} +% \end{syntax} +% +% +% +% \begin{macrocode} +\NewDocumentCommand{\ProvideGroupedTheoremFamily}{s O{} m} + { + \IfBooleanTF { #1 } + { + \groupthm_provide_grouped_theorem_family_from_keys:nn { #2 } { #3 } + } + { + \groupthm_provide_grouped_theorem_family_star_from_keys:nn { #2 } { #3 } + } + } +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\NewTheoremFamily,\NewTheoremFamily*} +% \begin{syntax} +% \cs{NewTheoremFamily}\oarg{keys}\marg{family name} +% \end{syntax} +% +% +% +% \begin{macrocode} +\NewDocumentCommand{\NewTheoremFamily}{s O{} m} + { + \IfBooleanTF { #1 } + { + \groupthm_new_theorem_family_from_keys:nn { #2 } { #3 } + } + { + \groupthm_new_theorem_family_star_from_keys:nn { #2 } { #3 } + } + } +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\ProvideTheoremFamily,\ProvideTheoremFamily*} +% \begin{syntax} +% \cs{ProvideTheoremFamily}\oarg{keys}\marg{family name} +% \end{syntax} +% +% +% +% \begin{macrocode} +\NewDocumentCommand{\ProvideTheoremFamily}{s O{} m} + { + \IfBooleanTF { #1 } + { + \groupthm_provide_theorem_family_from_keys:nn { #2 } { #3 } + } + { + \groupthm_provide_theorem_family_star_from_keys:nn { #2 } { #3 } + } + } +% \end{macrocode} +% \end{macro} +% +% +% % \begin{macrocode} % % \end{macrocode}