From 5b7e93e76ace2427b4798297609fe46f4f588c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Mon, 31 Jan 2022 21:26:41 +0100 Subject: [PATCH] also provide families lazily --- src/environments/groupthm/groupthm.dtx | 75 ++++++++++++++------------ 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/src/environments/groupthm/groupthm.dtx b/src/environments/groupthm/groupthm.dtx index b52e1d0..907b06d 100644 --- a/src/environments/groupthm/groupthm.dtx +++ b/src/environments/groupthm/groupthm.dtx @@ -1795,7 +1795,7 @@ { \@@_Declarator: TheoremGroup } { O{} m } { - \@@_lazy:n + \groupthm_do_cached:n { \use:c { groupthm_#1 _group:nn } { ##1 } { ##2 } } @@ -1853,7 +1853,7 @@ % \begin{macrocode} \NewDocumentCommand { \DeclareTheoremGroupRule } { O{??} m m m } { - \@@_lazy:n + \groupthm_do_cached:n { \groupthm_declare_group_rule:nnnn {#1} {#2} {#3} {#4} } @@ -1892,7 +1892,7 @@ % \begin{macrocode} \NewDocumentCommand { \AddTheoremGroupParent } { m m } { - \@@_lazy:n + \groupthm_do_cached:n { \groupthm_add_parent:nn { #1 } { #2 } } @@ -1982,7 +1982,7 @@ % \begin{macrocode} \NewDocumentCommand { \AppendToTheoremGroup } { O{} m } { - \@@_lazy:n { + \groupthm_do_cached:n { \groupthm_append_to_group:nn { #1 } { #2 } } } @@ -2300,7 +2300,7 @@ { \@@_Declarator: GroupedTheorem } { s O{} m } { - \@@_lazy:n + \groupthm_do_cached:n { \use:c { groupthm_#1_theorem:nnn } { ##2 } @@ -2453,7 +2453,7 @@ { \@@_Declarator: GroupedTheoremFamily } { s O{} m } { - \@@_lazy:n + \groupthm_do_cached:n { \use:c { groupthm_#1_family:nnn } { ##2 } @@ -2506,10 +2506,7 @@ % \begin{macrocode} \NewDocumentCommand { \AddTheoremToGroup } { m } { - \@@_lazy:n - { - \groupthm_add_theorem_to_group:n { #1 } - } + \groupthm_add_theorem_to_group:n { #1 } } % \end{macrocode} % \end{macro} @@ -2580,6 +2577,15 @@ \@@_sort_group_names: \end { __#1__groups_ \clist_use:Nn \l_@@_group_clist { _ } } } + \hook_gput_code:nnn { enddocument / afterlastpage } { groupthm } + { + \iow_now:cx { @auxout } + { + \token_to_str:N \ExplSyntaxOn + \exp_not:N \@@_define_family_options:nnnn { #1 } { #2 } { #3 } { #4 } + \token_to_str:N \ExplSyntaxOff + } + } } % \end{macrocode} % \end{macro} @@ -2642,30 +2648,33 @@ { \@@_Declarator: GroupedTheoremFamilyOptions } { s O{} m m m } { - \keys_set:nn { groupthm / theorem ~ family ~ options } { starred ~ version } - \keys_set:nn { groupthm / theorem ~ family ~ options } { ##2 } - \bool_if:nTF { ##1 } + \groupthm_do_cached:n { - \clist_set:Nn \l_tmpa_clist { unnumbered } - } - { - \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 - { + \keys_set:nn { groupthm / theorem ~ family ~ options } { starred ~ version } + \keys_set:nn { groupthm / theorem ~ family ~ options } { ##2 } + \bool_if:nTF { ##1 } + { + \clist_set:Nn \l_tmpa_clist { unnumbered } + } + { + \clist_clear:N \l_tmpa_clist + } \use:c { groupthm_#1_family_options:nnnV } - { ##3* } + { ##3 } { ##4 } - { - ##5 - \groupthm_add_theorem_to_group:n { starred } - } + { ##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} @@ -2680,9 +2689,9 @@ % % % -% \begin{macro}{\@@_lazy:n} +% \begin{macro}{\groupthm_do_cached:n} % \begin{syntax} -% \cs{@@_lazy:n}\marg{code} +% \cs{groupthm_do_cached:n}\marg{code} % \end{syntax} % % Executes this code lazy at beginning of the document, @@ -2692,7 +2701,7 @@ % if the aux file version was too old, otherwise dropped. % % \begin{macrocode} -\cs_new:Npn \@@_lazy:n +\cs_new:Npn \groupthm_do_cached:n { \bool_if:NTF \g_@@_cache_bool {