implement option interface for groupthm.

This commit is contained in:
Maximilian Keßler 2022-01-31 19:17:58 +01:00
parent 4bda829518
commit b041d8c990
2 changed files with 75 additions and 3 deletions

View file

@ -836,6 +836,7 @@
% \begin{macrocode} % \begin{macrocode}
\RequirePackage{amsthm} \RequirePackage{amsthm}
\RequirePackage{thmtools} \RequirePackage{thmtools}
\RequirePackage{l3keys2e}
% \end{macrocode} % \end{macrocode}
% %
% \begin{macro}{\@@_thmtools_declare_theorem:nn, \@@_thmtools_declare_theorem:Vn} % \begin{macro}{\@@_thmtools_declare_theorem:nn, \@@_thmtools_declare_theorem:Vn}
@ -965,6 +966,9 @@
\hook_new:n { @@/thmtools } \hook_new:n { @@/thmtools }
% \end{macrocode} % \end{macrocode}
% \begin{macrocode} % \begin{macrocode}
\hook_new:n { @@/definelazy }
% \end{macrocode}
% \begin{macrocode}
\hook_new:n { @@/groupsort } \hook_new:n { @@/groupsort }
% \end{macrocode} % \end{macrocode}
% %
@ -1047,6 +1051,10 @@
\bool_new:N \l_@@_in_family_options_environment_bool \bool_new:N \l_@@_in_family_options_environment_bool
% \end{macrocode} % \end{macrocode}
% \end{variable} % \end{variable}
%
%
%
%
% \begin{variable}{\g_@@_append_groups_int} % \begin{variable}{\g_@@_append_groups_int}
% %
% This counts the number of times we appended to a group. % This counts the number of times we appended to a group.
@ -1055,6 +1063,33 @@
\int_new:N \g_@@_append_groups_int \int_new:N \g_@@_append_groups_int
% \end{macrocode} % \end{macrocode}
% \end{variable} % \end{variable}
%
%
%
%
% \begin{variable}{\g_@@_cache_bool}
%
% This stores whether we cache definitions in the aux file.
%
% \begin{macrocode}
\bool_new:N \g_@@_cache_bool
% \end{macrocode}
% \end{variable}
%
%
%
% \begin{variable}{\g_@@_cache_version_aux_int, \g_@@_cache_version_document_int}
%
% The version of the cached theorems in the aux file
% and the version the package has been loaded with.
%
% \begin{macrocode}
\int_new:N \g_@@_cache_version_aux_int
\int_new:N \g_@@_cache_version_document_int
\int_set:Nn \g_@@_cache_version_aux_int { -1 }
% \end{macrocode}
% \end{variable}
%
% %
% %
% \subsection{Key interface} % \subsection{Key interface}
@ -1068,6 +1103,14 @@
% %
% %
% \begin{macrocode} % \begin{macrocode}
\keys_define:nn { groupthm }
{
cache .bool_set:N = \g_@@_cache_bool,
cache .default:n = { true },
__cache version__ .int_set:N = \g_@@_cache_version_document_int,
cache version .meta:nn = { groupthm } { cache = true, __cache version__ = #1 },
cache version .default:n = { 0 },
}
\keys_define:nn { groupthm / theorem ~ group } \keys_define:nn { groupthm / theorem ~ group }
{ {
prefix .tl_set:N = \l_@@_key_prefix_tl, prefix .tl_set:N = \l_@@_key_prefix_tl,
@ -1118,6 +1161,13 @@
} }
% \end{macrocode} % \end{macrocode}
% %
%
%
% Process package options:
% \begin{macrocode}
\ProcessKeysOptions { groupthm }
% \end{macrocode}
%
% %
% The only key whose default requires such handling is the \enquote{\texttt{name}} key, % 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 % which will be set to a capitalized version of the environment name
@ -1918,11 +1968,13 @@
% %
% We also provide the three default groups: % We also provide the three default groups:
% %
% \begin{variable}{all, starred, unnumbered}
% \begin{macrocode} % \begin{macrocode}
\groupthm_new_group:nnnnn { all } { } { } { } { } \groupthm_new_group:nnnnn { all } { } { } { } { }
\groupthm_new_group:nnnnn { starred } { } { } { } { numbered = no } \groupthm_new_group:nnnnn { starred } { } { } { } { numbered = no }
\groupthm_new_group:nnnnn { unnumbered } { } { } { } { numbered = no } \groupthm_new_group:nnnnn { unnumbered } { } { } { } { numbered = no }
% \end{macrocode} % \end{macrocode}
% \end{variable}
% %
% \subsection{Iterating over powersets} % \subsection{Iterating over powersets}
% For generating the different variants of a theorem family, % For generating the different variants of a theorem family,
@ -2224,10 +2276,27 @@
{ \@@_Declarator: GroupedTheorem } { \@@_Declarator: GroupedTheorem }
{ s O{} m } { s O{} m }
{ {
\use:c { groupthm_#1_theorem:nnn } \bool_if:nTF
{
\g_@@_cache_bool
&&
\int_compare_p:n
{
\g_@@_cache_version_aux_int < \g_@@_cache_version_document_int
}
}
{
\hook_gput_code:nnn {@@/lazy} { groupthm }
}
{
\use:n
}
{
\use:c { groupthm_#1_theorem:nnn }
{ ##2 } { ##2 }
{ ##3 } { ##3 }
{ ##1 } { ##1 }
}
} }
% \end{macrocode} % \end{macrocode}
% \end{macro} % \end{macro}
@ -2585,8 +2654,11 @@
} }
% \end{macrocode} % \end{macrocode}
% \end{macro} % \end{macro}
% %
% %
%
%
% \subsection{Caching}
% %
% %
% %