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.
@ -1057,6 +1065,33 @@
% \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}
% As mentioned, all keys will set their corresponding local variables % As mentioned, all keys will set their corresponding local variables
% (containing \enquote{\texttt{_key_}} in their name) and store the % (containing \enquote{\texttt{_key_}} in their name) and store the
@ -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,
@ -1119,6 +1162,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
% when not specified. % when not specified.
@ -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}
@ -2589,6 +2658,9 @@
% %
% %
% %
% \subsection{Caching}
%
%
% %
% \begin{macrocode} % \begin{macrocode}
%</package> %</package>