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}
\RequirePackage{amsthm}
\RequirePackage{thmtools}
\RequirePackage{l3keys2e}
% \end{macrocode}
%
% \begin{macro}{\@@_thmtools_declare_theorem:nn, \@@_thmtools_declare_theorem:Vn}
@ -965,6 +966,9 @@
\hook_new:n { @@/thmtools }
% \end{macrocode}
% \begin{macrocode}
\hook_new:n { @@/definelazy }
% \end{macrocode}
% \begin{macrocode}
\hook_new:n { @@/groupsort }
% \end{macrocode}
%
@ -1047,6 +1051,10 @@
\bool_new:N \l_@@_in_family_options_environment_bool
% \end{macrocode}
% \end{variable}
%
%
%
%
% \begin{variable}{\g_@@_append_groups_int}
%
% This counts the number of times we appended to a group.
@ -1055,6 +1063,33 @@
\int_new:N \g_@@_append_groups_int
% \end{macrocode}
% \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}
@ -1068,6 +1103,14 @@
%
%
% \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 }
{
prefix .tl_set:N = \l_@@_key_prefix_tl,
@ -1118,6 +1161,13 @@
}
% \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,
% which will be set to a capitalized version of the environment name
@ -1918,11 +1968,13 @@
%
% We also provide the three default groups:
%
% \begin{variable}{all, starred, unnumbered}
% \begin{macrocode}
\groupthm_new_group:nnnnn { all } { } { } { } { }
\groupthm_new_group:nnnnn { starred } { } { } { } { numbered = no }
\groupthm_new_group:nnnnn { unnumbered } { } { } { } { numbered = no }
% \end{macrocode}
% \end{variable}
%
% \subsection{Iterating over powersets}
% For generating the different variants of a theorem family,
@ -2224,10 +2276,27 @@
{ \@@_Declarator: GroupedTheorem }
{ 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 }
{ ##3 }
{ ##1 }
}
}
% \end{macrocode}
% \end{macro}
@ -2585,8 +2654,11 @@
}
% \end{macrocode}
% \end{macro}
%
%
%
%
%
%
% \subsection{Caching}
%
%
%