fix some more bugs

This commit is contained in:
Maximilian Keßler 2022-01-18 03:54:34 +01:00
parent 808b8c457f
commit 1f3aa04bfe
2 changed files with 615 additions and 28 deletions

View file

@ -843,22 +843,21 @@
% \begin{macrocode} % \begin{macrocode}
\RequirePackage{amsthm} \RequirePackage{amsthm}
\RequirePackage{thmtools} \RequirePackage{thmtools}
\RequirePackage{mkessler-powerset}
% \end{macrocode} % \end{macrocode}
% %
% \begin{macro}{\@@_declare_theorem_group:nn, \@@_declare_theorem_group:nV} % \begin{macro}{\@@_thmtools_declare_theorem:nn, \@@_thmtools_declare_theorem:Vn}
% \begin{syntax} % \begin{syntax}
% \cs{@@_declare_theorem_group:nn} \meta{theorem name}\meta{thmtools keyval args} % \cs{@@_thmtools_declare_theorem:nn} \meta{theorem name}\meta{thmtools keyval args}
% \end{syntax} % \end{syntax}
% %
% This is just a private wrapper around \cs{declaretheorem} of the \pkg{thmtools} package. % This is just a private wrapper around \cs{declaretheorem} of the \pkg{thmtools} package.
% %
% \begin{macrocode} % \begin{macrocode}
\cs_new:Npn \@@_declare_theorem_group:nn #1 #2 \cs_new:Npn \@@_thmtools_declare_theorem:nn #1 #2
{ {
\declaretheorem [ #2 ] { #1 } \declaretheorem [ #1 ] { #2 }
} }
\cs_generate_variant:Nn \@@_declare_theorem_group:nn { n V } \cs_generate_variant:Nn \@@_thmtools_declare_theorem:nn { V n }
% \end{macrocode} % \end{macrocode}
% \end{macro} % \end{macro}
% %
@ -1788,13 +1787,13 @@
% Finally, apply the additional \pkg{thmtools} keys for this specific theorem. % Finally, apply the additional \pkg{thmtools} keys for this specific theorem.
% Putting them last will overwrite keys that were given by the groups. % Putting them last will overwrite keys that were given by the groups.
% \begin{macrocode} % \begin{macrocode}
\clist_put_right:n \l_@@_thmtools_clist { #4 } \clist_put_right:Nn \l_@@_thmtools_clist { #4 }
% \end{macrocode} % \end{macrocode}
% We can now pass our list to \pkg{thmtools}, declaring the theorem. % We can now pass our list to \pkg{thmtools}, declaring the theorem.
% \begin{macrocode} % \begin{macrocode}
\@@_declare_theorem:nV \@@_thmtools_declare_theorem:Vn
{ #1 }
\l_@@_thmtools_clist \l_@@_thmtools_clist
{ #1 }
} }
% \end{macrocode} % \end{macrocode}
% \end{macro} % \end{macro}
@ -1806,7 +1805,7 @@
% %
% %
% %
% \begin{macro}{\groupthm_new_grouped_theorem:nnnn} % \begin{macro}{\groupthm_new_grouped_theorem:nnnn,\groupthm_new_grouped_theorem:nVVV}
% \begin{syntax} % \begin{syntax}
% \cs{groupthm_new_grouped_theorem:nnnn}\ma{environment name} % \cs{groupthm_new_grouped_theorem:nnnn}\ma{environment name}
% \ma{groups clist}\ma{theorem name}\ma{thmtools keys} % \ma{groups clist}\ma{theorem name}\ma{thmtools keys}
@ -1822,19 +1821,20 @@
% \begin{macrocode} % \begin{macrocode}
\cs_if_exist:cTF { #1 } \cs_if_exist:cTF { #1 }
{ {
\msg_error:{ groupthm } { wrong ~ definition } \msg_error:nnnnn { groupthm } { wrong ~ definition }
{ grouped ~ theorem } { #1 } { already } { grouped ~ theorem } { #1 } { already }
} }
{ {
\@@_groupthm_declare_grouped_theorem_aux:nnnn \@@_declare_grouped_theorem_aux:nnnn
{ #1 } { #2 } { #3 } { #4 } { #1 } { #2 } { #3 } { #4 }
} }
} }
\cs_generate_variant:Nn \groupthm_new_grouped_theorem:nnnn { n V V V }
% \end{macrocode} % \end{macrocode}
% \end{macro} % \end{macro}
% %
% %
% \begin{macro}{\groupthm_provide_grouped_theorem:nnnn} % \begin{macro}{\groupthm_provide_grouped_theorem:nnnn,\groupthm_provide_grouped_theorem:nVVV}
% %
% \begin{macrocode} % \begin{macrocode}
\cs_new:Npn \groupthm_provide_grouped_theorem:nnnn #1 #2 #3 #4 \cs_new:Npn \groupthm_provide_grouped_theorem:nnnn #1 #2 #3 #4
@ -1846,10 +1846,11 @@
% \begin{macrocode} % \begin{macrocode}
\cs_if_exist:cF { #1 } \cs_if_exist:cF { #1 }
{ {
\@@_groupthm_declare_grouped_theorem_aux:nnnn \@@_declare_grouped_theorem_aux:nnnn
{ #1 } { #2 } { #3 } { #4 } { #1 } { #2 } { #3 } { #4 }
} }
} }
\cs_generate_variant:Nn \groupthm_provide_grouped_theorem:nnnn { n V V V }
% \end{macrocode} % \end{macrocode}
% \end{macro} % \end{macro}
% %
@ -1893,7 +1894,7 @@
% %
% %
% %
% \begin{macro}{\groupthm_new_theorem:nnnn} % \begin{macro}{\groupthm_new_theorem:nnnn,\groupthm_new_theorem:nVVV}
% \begin{syntax} % \begin{syntax}
% \cs{groupthm_new_theorem:nnnn}\ma{environment name} % \cs{groupthm_new_theorem:nnnn}\ma{environment name}
% \ma{groups clist}\ma{theorem name}\ma{thmtools keys} % \ma{groups clist}\ma{theorem name}\ma{thmtools keys}
@ -1908,12 +1909,13 @@
\groupthm_new_grouped_theorem:nnnn \groupthm_new_grouped_theorem:nnnn
{ #1* } { #2, starred } { #3 } { #4 } { #1* } { #2, starred } { #3 } { #4 }
} }
\cs_generate_variant:Nn \groupthm_new_theorem:nnnn { n V V V }
% \end{macrocode} % \end{macrocode}
% \end{macro} % \end{macro}
% %
% %
% %
% \begin{macro}{\groupthm_provide_theorem:nnnn} % \begin{macro}{\groupthm_provide_theorem:nnnn,\groupthm_provide_theorem:nVVV}
% \begin{syntax} % \begin{syntax}
% \cs{groupthm_provide_theorem:nnnn}\ma{environment name} % \cs{groupthm_provide_theorem:nnnn}\ma{environment name}
% \ma{groups clist}\ma{theorem name}\ma{thmtools keys} % \ma{groups clist}\ma{theorem name}\ma{thmtools keys}
@ -1928,6 +1930,7 @@
\groupthm_provide_grouped_theorem:nnnn \groupthm_provide_grouped_theorem:nnnn
{ #1* } { #2, starred } { #3 } { #4 } { #1* } { #2, starred } { #3 } { #4 }
} }
\cs_generate_variant:Nn \groupthm_provide_theorem:nnnn { n V V V }
% \end{macrocode} % \end{macrocode}
% \end{macro} % \end{macro}
% %
@ -1979,7 +1982,7 @@
% \begin{macrocode} % \begin{macrocode}
\cs_new:Npn \groupthm_new_grouped_theorem_from_keys:nn #1 #2 \cs_new:Npn \groupthm_new_grouped_theorem_from_keys:nn #1 #2
{ {
\@@_set_normalized_keys { #2 } { groupedtheorem } { #1 } \@@_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_new_grouped_theorem:nVVV \groupthm_new_grouped_theorem:nVVV
{ #1 } { #1 }
@ -1995,7 +1998,7 @@
% \begin{macrocode} % \begin{macrocode}
\cs_new:Npn \groupthm_provide_grouped_theorem_from_keys:nn #1 #2 \cs_new:Npn \groupthm_provide_grouped_theorem_from_keys:nn #1 #2
{ {
\@@_set_normalized_keys { #2 } { groupedtheorem } { #1 } \@@_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_provide_grouped_theorem:nVVV \groupthm_provide_grouped_theorem:nVVV
{ #1 } { #1 }
@ -2011,10 +2014,10 @@
% \begin{macrocode} % \begin{macrocode}
\cs_new:Npn \groupthm_new_grouped_theorem_star_from_keys:nn #1 #2 \cs_new:Npn \groupthm_new_grouped_theorem_star_from_keys:nn #1 #2
{ {
\@@_set_normalized_keys { #2 } { groupedtheorem } { #1 } \@@_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_new_grouped_theorem_star:nVVV \groupthm_new_grouped_theorem_star:nVVV
{ #1 } { #2 }
\l_@@_key_group_clist \l_@@_key_group_clist
\l_@@_name_tl \l_@@_name_tl
\l_@@_key_thmtools_clist \l_@@_key_thmtools_clist
@ -2027,10 +2030,10 @@
% \begin{macrocode} % \begin{macrocode}
\cs_new:Npn \groupthm_provide_grouped_theorem_star_from_keys:nn #1 #2 \cs_new:Npn \groupthm_provide_grouped_theorem_star_from_keys:nn #1 #2
{ {
\@@_set_normalized_keys { #2 } { groupedtheorem } { #1 } \@@_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_provide_grouped_theorem_star:nVVV \groupthm_provide_grouped_theorem_star:nVVV
{ #1 } { #2 }
\l_@@_key_group_clist \l_@@_key_group_clist
\l_@@_name_tl \l_@@_name_tl
\l_@@_key_thmtools_clist \l_@@_key_thmtools_clist
@ -2044,10 +2047,10 @@
% \begin{macrocode} % \begin{macrocode}
\cs_new:Npn \groupthm_new_theorem_from_keys:nn #1 #2 \cs_new:Npn \groupthm_new_theorem_from_keys:nn #1 #2
{ {
\@@_set_normalized_keys { #2 } { groupedtheorem } { #1 } \@@_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_new_theorem:nVVV \groupthm_new_theorem:nVVV
{ #1 } { #2 }
\l_@@_key_group_clist \l_@@_key_group_clist
\l_@@_name_tl \l_@@_name_tl
\l_@@_key_thmtools_clist \l_@@_key_thmtools_clist
@ -2060,10 +2063,10 @@
% \begin{macrocode} % \begin{macrocode}
\cs_new:Npn \groupthm_provide_theorem_from_keys:nn #1 #2 \cs_new:Npn \groupthm_provide_theorem_from_keys:nn #1 #2
{ {
\@@_set_normalized_keys { #2 } { groupedtheorem } { #1 } \@@_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_provide_theorem:nVVV \groupthm_provide_theorem:nVVV
{ #1 } { #2 }
\l_@@_key_group_clist \l_@@_key_group_clist
\l_@@_name_tl \l_@@_name_tl
\l_@@_key_thmtools_clist \l_@@_key_thmtools_clist
@ -2076,7 +2079,7 @@
% \begin{macrocode} % \begin{macrocode}
\cs_new:Npn \groupthm_new_theorem_star_from_keys:nn #1 #2 \cs_new:Npn \groupthm_new_theorem_star_from_keys:nn #1 #2
{ {
\@@_set_normalized_keys { #2 } { groupedtheorem } { #1 } \@@_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_new_theorem_star:nVVV \groupthm_new_theorem_star:nVVV
{ #1 } { #1 }
@ -2092,7 +2095,7 @@
% \begin{macrocode} % \begin{macrocode}
\cs_new:Npn \groupthm_provide_theorem_star_from_keys:nn #1 #2 \cs_new:Npn \groupthm_provide_theorem_star_from_keys:nn #1 #2
{ {
\@@_set_normalized_keys { #2 } { groupedtheorem } { #1 } \@@_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_provide_theorem_star:nVVV \groupthm_provide_theorem_star:nVVV
{ #1 } { #1 }

View file

@ -0,0 +1,584 @@
%%
%% This is file `groupthm.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% groupthm.dtx (with options: `package')
%%
%% IMPORTANT NOTICE:
%%
%% For the copyright see the source file.
%%
%% Any modified versions of this file must be renamed
%% with new filenames distinct from groupthm.sty.
%%
%% For distribution of the original source see the terms
%% for copying and modification in the file groupthm.dtx.
%%
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%% File: groupthm.dtx
\ProvidesExplPackage{groupthm}{2022/01/17}{0.0.1}{Grouped theorems.}
\RequirePackage{amsthm}
\RequirePackage{thmtools}
\cs_new:Npn \__groupthm_thmtools_declare_theorem:nn #1 #2
{
\declaretheorem [ #1 ] { #2 }
}
\cs_generate_variant:Nn \__groupthm_thmtools_declare_theorem:nn { V n }
\cs_new:Npn \__groupthm_hook_gset_rule_foreach:nNnn #1 #2 #3 #4
{
\cs_set:Npn \__groupthm_map_aux:n ##1
{
\hook_gset_rule:nnnn { #1 } { ##1 } { #3 } { #4 }
}
\clist_map_function:NN #2 \__groupthm_map_aux:n
}
\msg_new:nnn { groupthm } { unknown ~ group }
{
Unknown ~ group ~ '#1' ~ supplied ~ \msg_line_context:
}
\msg_new:nnn { groupthm } { unknown ~ key }
{
Unknown ~ key ~ '#1' ~ supplied ~ \msg_line_context:
}
\msg_new:nnn { groupthm } { wrong ~ definition }
{
Bad ~ definition ~ of ~ #1 ~ '#2' ~ \msg_line_context:, ~ #1 ~ is ~ #3 ~ defined.
}
\hook_new:n { __groupthm/prename }
\hook_new:n { __groupthm/postname }
\hook_new:n { __groupthm/mapname }
\hook_new:n { __groupthm/thmtools }
\hook_new:n { __groupthm/groupsort }
\cs_generate_variant:Nn \hook_gset_rule:nnnn { n n V n }
\tl_new:N \l__groupthm_key_prename_tl
\tl_new:N \l__groupthm_key_name_tl
\tl_new:N \l__groupthm_key_postname_tl
\clist_new:N \l__groupthm_key_group_clist
\clist_new:N \l__groupthm_key_mapname_clist
\clist_new:N \l__groupthm_key_thmtools_clist
\tl_new:N \l__groupthm_prename_tl
\tl_new:N \l__groupthm_name_tl
\tl_new:N \l__groupthm_postname_tl
\clist_new:N \l__groupthm_mapname_clist
\clist_new:N \l__groupthm_thmtools_clist
\clist_new:N \l__groupthm_group_clist
\clist_new:N \g__groupthm_defined_theorem_groups_clist
\keys_define:nn { groupthm }
{
prename .tl_set:N = \l__groupthm_key_prename_tl,
prename .default:n = \c_empty_tl,
prename .groups:n = { theoremgroup },
name .tl_set:N = \l__groupthm_key_name_tl,
name .default:n = \c_novalue_tl,
name .groups:n = { groupedtheorem, theoremvariants },
postname .tl_set:N = \l__groupthm_key_postname_tl,
postname .default:n = \c_empty_tl,
postname .groups:n = { theoremgroup },
group .clist_set:N = \l__groupthm_key_group_clist,
group .default:n = {},
group .groups:n = { groupedtheorem, theoremvariants },
mapname .clist_set:N = \l__groupthm_mapname_clist,
mapname .default:n = {},
mapname .groups:n = { theoremgroup },
thmtools .clist_set:N = \l__groupthm_key_thmtools_clist,
thmtools .default:n = {},
thmtools .groups:n =
{ theoremgroup, groupedtheorem, theoremvariants },
unknown .code:n =
\msg_error:nnn { groupthm } { unknown ~ group } { \l_keys_key_str }
}
\cs_new:Npn \__groupthm_set_normalized_keys:nnn #1 #2 #3
{
\keys_set:nn { groupthm } { prename, name, postname, group, mapname, thmtools }
\keys_set_groups:nnn { groupthm } { #2 } { #1 }
\tl_if_eq:NnTF \l__groupthm_key_name_tl { \c_novalue_tl }
{
\tl_set:Nx \l__groupthm_name_tl
{
\text_titlecase_first:n {#3}
}
}
{
\tl_set_eq:NN \l__groupthm_name_tl \l__groupthm_key_name_tl
}
\tl_set_eq:NN \l__groupthm_prename_tl \l__groupthm_key_prename_tl
\tl_set_eq:NN \l__groupthm_postname_tl \l__groupthm_key_postname_tl
\clist_set_eq:NN \l__groupthm_group_clist \l__groupthm_key_group_clist
\clist_set_eq:NN \l__groupthm_mapname_clist \l__groupthm_key_mapname_clist
\clist_set_eq:NN \l__groupthm_thmtools_clist \l__groupthm_key_thmtools_clist
}
\cs_new:Npn \__groupthm_add_to_theorem_group_ordering:n #1
{
\__groupthm_hook_gset_rule_foreach:nNnn
{ __groupthm/groupsort }
\g__groupthm_defined_theorem_groups_clist
{ before }
{ #1 }
}
\cs_new:Npn \__groupthm_remove_from_theorem_group_ordering:n #1
{
\__groupthm_hook_gset_rule_foreach:nNnn
{ __groupthm/groupsort }
\g__groupthm_defined_theorem_groups_clist
{ unrelated }
{ #1 }
}
\cs_new:Npn \__groupthm_add_to_sort_hook:n #1
{
\hook_gput_code:nnn { __groupthm/groupsort }
{ #1 }
{
\clist_put_left:Nn \l__groupthm_group_clist { #1 }
}
}
\cs_new:Npn \__groupthm_sort_theorem_group_names:
{
\hook_gremove_code:nn { __groupthm/groupsort }{*}
\clist_map_function:NN \l__groupthm_group_clist \__add_to_sort_hook:n
\clist_clear:N \l__groupthm_group_clist
\hook_use:n { __groupthm/groupsort }
}
\cs_new:Npn \__groupthm_declare_theorem_group_aux:nnnnn #1#2#3#4#5
{
\cs_new:cpn { __groupthm_use_group_#1: }
{
\hook_gput_code:nnn { __groupthm/prename } { #1 }
{
\tl_put_left:Nx \l__groupthm_prename_tl { #2 }
}
\hook_gput_code:nnn { __groupthm/postname } { #1 }
{
\tl_put_right:Nx \l__groupthm_postname_tl { #3 }
}
\hook_gput_code:nnn { __groupthm/mapname } { #1 }
{
\clist_put_right:Nn \l__groupthm_mapname_clist { #4 }
}
\hook_gput_code:nnn { __groupthm/thmtools } { #1 }
{
\clist_put_right:Nn \l__groupthm_thmtools_clist { #5 }
}
}
\__groupthm_add_to_theorem_group_ordering:n { #1 }
\clist_gput_left:Nn \g__groupthm_defined_theorem_groups_clist { #1 }
}
\cs_new:Npn \__groupthm_undeclare_theorem_group_aux:n #1
{
\cs_undefine:c { __groupthm_use_group_#1: }
\hook_gremove_code:nn { __groupthm/prename } { #1 }
\hook_gremove_code:nn { __groupthm/postname } { #1 }
\hook_gremove_code:nn { __groupthm/mapname } { #1 }
\hook_gremove_code:nn { __groupthm/thmtools } { #1 }
\clist_gremove_all:Nn \g__groupthm_defined_theorem_groups_clist { #1 }
\__groupthm_hook_gset_rule_foreach:nNnn
{ ?? }
\g__groupthm_defined_theorem_groups_clist
{ unrelated }
{ #1 }
\__groupthm_hook_gset_rule_foreach:nNnn
{ __groupthm/prename }
\g__groupthm_defined_theorem_groups_clist
{ unrelated }
{ #1 }
\__groupthm_hook_gset_rule_foreach:nNnn
{ __groupthm/postname }
\g__groupthm_defined_theorem_groups_clist
{ unrelated }
{ #1 }
\__groupthm_hook_gset_rule_foreach:nNnn
{ __groupthm/mapname }
\g__groupthm_defined_theorem_groups_clist
{ unrelated }
{ #1 }
\__groupthm_hook_gset_rule_foreach:nNnn
{ __groupthm/thmtools }
\g__groupthm_defined_theorem_groups_clist
{ unrelated }
{ #1 }
\__groupthm_remove_from_theorem_group_ordering:n { #1 }
}
\cs_new:Npn \groupthm_new_theorem_group:nnnnn #1 #2 #3 #4 #5
{
\cs_if_exist:cTF { __groupthm_use_group_#1: }
{
\msg_error:nnnnn { groupthm } { wrong ~ definition }
{ theorem ~ group } { #1 } { already }
}
{
\__groupthm_declare_theorem_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 }
}
}
\cs_generate_variant:Nn \groupthm_new_theorem_group:nnnnn { n V V V V }
\cs_new:Npn \groupthm_renew_theorem_group:nnnnn #1 #2 #3 #4 #5
{
\cs_if_exist:cTF { __groupthm_use_group_#1: }
{
\__groupthm_undeclare_theorem_group_aux:n { #1 }
\__groupthm_declare_theorem_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 }
}
{
\msg_error:nnnnn { groupthm } { wrong ~ definition }
{ theorem ~ group } { #1 } { not }
}
}
\cs_generate_variant:Nn \groupthm_renew_theorem_group:nnnnn { n V V V V }
\cs_new:Npn \groupthm_provide_theorem_group:nnnnn #1 #2 #3 #4 #5
{
\cs_if_exist:cF { __groupthm_use_group_#1: }
{
\__groupthm_declare_theorem_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 }
}
}
\cs_generate_variant:Nn \groupthm_provide_theorem_group:nnnnn { n V V V V }
\cs_new:Npn \groupthm_declare_theorem_group:nnnnn #1 #2 #3 #4 #5
{
\cs_if_exist:cT { __groupthm_use_group_#1: }
{
\__groupthm_undeclare_theorem_group_aux:n { #1 }
}
\__groupthm_declare_theorem_group_aux:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 }
}
\cs_generate_variant:Nn \groupthm_declare_theorem_group:nnnnn { n V V V V }
\cs_new:Npn \groupthm_new_theorem_group_from_keys:nn #1#2
{
\__groupthm_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 }
\groupthm_new_theorem_group:nVVVV { #2 }
\l__groupthm_prename_tl
\l__groupthm_postname_tl
\l__groupthm_mapname_clist
\l__groupthm_thmtools_clist
}
\cs_new:Npn \groupthm_renew_theorem_group_from_keys:nn #1#2
{
\__groupthm_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 }
\groupthm_renew_theorem_group:nVVVV { #2 }
\l__groupthm_prename_tl
\l__groupthm_postname_tl
\l__groupthm_mapname_clist
\l__groupthm_thmtools_clist
}
\cs_new:Npn \groupthm_provide_theorem_group_from_keys:nn #1#2
{
\__groupthm_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 }
\groupthm_provide_theorem_group:nVVVV { #2 }
\l__groupthm_prename_tl
\l__groupthm_postname_tl
\l__groupthm_mapname_clist
\l__groupthm_thmtools_clist
}
\cs_new:Npn \groupthm_declare_theorem_group_from_keys:nn #1#2
{
\__groupthm_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 }
\groupthm_declare_theorem_group:nVVVV { #2 }
\l__groupthm_prename_tl
\l__groupthm_postname_tl
\l__groupthm_mapname_clist
\l__groupthm_thmtools_clist
}
\NewDocumentCommand{\NewTheoremGroup}{ O{} m }
{
\groupthm_new_theorem_group_from_keys:nn { #1 } { #2 }
}
\NewDocumentCommand{\RenewTheoremGroup}{ O{} m }
{
\groupthm_renew_theorem_group_from_keys:nn { #1 } { #2 }
}
\NewDocumentCommand{\ProvideTheoremGroup}{ O{} m }
{
\groupthm_provide_theorem_group_from_keys:nn { #1 } { #2 }
}
\NewDocumentCommand{\DeclareTheoremGroup}{ O{} m }
{
\groupthm_declare_theorem_group_from_keys:nn { #1 } { #2 }
}
\cs_new:Npn \groupthm_declare_theorem_group_rule:nnnn #1 #2 #3 #4
{
\str_set:Nx \l_tmpa_str { \tl_trim_spaces:n { #3 } }
\str_if_eq:VnT \l_tmpa_str { higher }
{
\str_set:Nn \l_tmpa_tl { after }
}
\str_if_eq:VnT \l_tmpa_str { lower }
{
\str_set:Nn \l_tmpa_tl { before }
}
\str_if_eq:nnTF { #1 } { ?? }
{
\hook_gset_rule:nnVn {??} {#2} \l_tmpa_tl {#4}
}
{
\hook_gset_rule:nnVn { __groupthm / #1 } {#2} \l_tmpa_tl {#4}
}
}
\NewDocumentCommand { \DeclareTheoremGroupRule } { O{??} m m m }
{
\groupthm_declare_theorem_group_rule:nnnn {#1} {#2} {#3} {#4}
}
% \subsection{Iterating over powersets}
\clist_new:N \l__powerset_copied_clist
\seq_new:N \l__powerset_saved_seq
\cs_generate_variant:Nn \clist_remove_all:Nn { N V }
\cs_new:Npn \__powerset_clist_foreach_aux:Nn #1 #2
{
\clist_if_empty:NTF \l__powerset_copied_clist
{
#2
}
{
\clist_get:NN \l__powerset_copied_clist \l_tmpa_tl
\seq_push:NV \l__powerset_saved_seq \l_tmpa_tl
\clist_pop:NN \l__powerset_copied_clist { \l_tmpa_tl }
\__powerset_clist_foreach_aux:Nn #1 {#2}
\seq_get:NN \l__powerset_saved_seq \l_tmpa_tl
\clist_put_left:NV #1 \l_tmpa_tl
\__powerset_clist_foreach_aux:Nn #1 {#2}
\seq_get:NN \l__powerset_saved_seq \l_tmpa_tl
\clist_remove_all:NV #1 \l_tmpa_tl
\clist_push:NV \l__powerset_copied_clist \l_tmpa_tl
\seq_pop:NN \l__powerset_saved_seq \l_tmpa_tl
}
}
\cs_new:Npn \powerset_clist_foreach:Nn #1 #2
{
\clist_set_eq:NN \l__powerset_copied_clist #1
\clist_clear:N #1
\clist_remove_duplicates:N \l__powerset_copied_clist
\__powerset_clist_foreach_aux:Nn #1 {#2}
\clist_set_eq:NN #1 \l__powerset_copied_clist
}
\cs_new:Npn \__groupthm_use_theorem_group:n #1
{
\cs_if_exist_use:cF { __groupthm_use_group_#1: }
{
\msg_error:nnn { groupthm } { unknown ~ group } { #1 }
}
}
\cs_new:Npn \__groupthm_use_function_on_name:n #1
{
\tl_set:Nx \l__groupthm_name_tl
{
#1 { \tl_use:N \l__groupthm_name_tl }
}
}
\cs_new:Npn \__groupthm_declare_grouped_theorem_aux:nnnn #1 #2 #3 #4
{
\tl_clear:N \l__groupthm_prename_tl
\tl_set:Nn \l__groupthm_name_tl { #3 }
\tl_clear:N \l__groupthm_postname_tl
\clist_clear:N \l__groupthm_mapname_clist
\clist_clear:N \l__groupthm_thmtools_clist
\hook_gremove_code:nn { __groupthm/prename }{*}
\hook_gremove_code:nn { __groupthm/postname }{*}
\hook_gremove_code:nn { __groupthm/mapname }{*}
\hook_gremove_code:nn { __groupthm/thmtools }{*}
\clist_map_function:nN { #2 } \__groupthm_use_theorem_group:n
\hook_use:n { __groupthm/prename }
\hook_use:n { __groupthm/postname }
\hook_use:n { __groupthm/mapname }
\hook_use:n { __groupthm/thmtools }
\clist_map_function:NN \l__groupthm_mapname_clist \map_use_on_name:n
\clist_put_right:Nx \l__groupthm_thmtools_clist
{
name = \tl_use:N \l__groupthm_prename_tl
\tl_use:N \l__groupthm_name_tl
\tl_use:N \l__groupthm_postname_tl
}
\clist_put_right:Nn \l__groupthm_thmtools_clist { #4 }
\__groupthm_thmtools_declare_theorem:Vn
\l__groupthm_thmtools_clist
{ #1 }
}
\cs_new:Npn \groupthm_new_grouped_theorem:nnnn #1 #2 #3 #4
{
\cs_if_exist:cTF { #1 }
{
\msg_error:nnnnn { groupthm } { wrong ~ definition }
{ grouped ~ theorem } { #1 } { already }
}
{
\__groupthm_declare_grouped_theorem_aux:nnnn
{ #1 } { #2 } { #3 } { #4 }
}
}
\cs_generate_variant:Nn \groupthm_new_grouped_theorem:nnnn { n V V V }
\cs_new:Npn \groupthm_provide_grouped_theorem:nnnn #1 #2 #3 #4
{
\cs_if_exist:cF { #1 }
{
\__groupthm_declare_grouped_theorem_aux:nnnn
{ #1 } { #2 } { #3 } { #4 }
}
}
\cs_generate_variant:Nn \groupthm_provide_grouped_theorem:nnnn { n V V V }
\cs_new:Npn \groupthm_new_grouped_theorem_star:nnnn #1 #2 #3 #4
{
\groupthm_new_grouped_theorem:nnnn
{ #1 } { #2, unnumbered } { #3 } { #4 }
}
\cs_new:Npn \groupthm_provide_grouped_theorem_star:nnnn #1 #2 #3 #4
{
\groupthm_provide_grouped_theorem:nnnn
{ #1 } { #2, unnumbered } { #3 } { #4 }
}
\cs_new:Npn \groupthm_new_theorem:nnnn #1 #2 #3 #4
{
\groupthm_new_grouped_theorem:nnnn
{ #1 } { #2 } { #3 } { #4 }
\groupthm_new_grouped_theorem:nnnn
{ #1* } { #2, starred } { #3 } { #4 }
}
\cs_generate_variant:Nn \groupthm_new_theorem:nnnn { n V V V }
\cs_new:Npn \groupthm_provide_theorem:nnnn #1 #2 #3 #4
{
\groupthm_provide_grouped_theorem:nnnn
{ #1 } { #2 } { #3 } { #4 }
\groupthm_provide_grouped_theorem:nnnn
{ #1* } { #2, starred } { #3 } { #4 }
}
\cs_generate_variant:Nn \groupthm_provide_theorem:nnnn { n V V V }
\cs_new:Npn \groupthm_new_theorem_star:nnnn #1 #2 #3 #4
{
\groupthm_new_theorem:nnnn
{ #1 } { #2, unnumbered } { #3 } { #4 }
}
\cs_new:Npn \groupthm_provide_theorem_star:nnnn #1 #2 #3 #4
{
\groupthm_provide_theorem:nnnn
{ #1 } { #2, unnumbered } { #3 } { #4 }
}
\cs_new:Npn \groupthm_new_grouped_theorem_from_keys:nn #1 #2
{
\__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_new_grouped_theorem:nVVV
{ #1 }
\l__groupthm_key_group_clist
\l__groupthm_name_tl
\l__groupthm_key_thmtools_clist
}
\cs_new:Npn \groupthm_provide_grouped_theorem_from_keys:nn #1 #2
{
\__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_provide_grouped_theorem:nVVV
{ #1 }
\l__groupthm_key_group_clist
\l__groupthm_name_tl
\l__groupthm_key_thmtools_clist
}
\cs_new:Npn \groupthm_new_grouped_theorem_star_from_keys:nn #1 #2
{
\__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_new_grouped_theorem_star:nVVV
{ #2 }
\l__groupthm_key_group_clist
\l__groupthm_name_tl
\l__groupthm_key_thmtools_clist
}
\cs_new:Npn \groupthm_provide_grouped_theorem_star_from_keys:nn #1 #2
{
\__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_provide_grouped_theorem_star:nVVV
{ #2 }
\l__groupthm_key_group_clist
\l__groupthm_name_tl
\l__groupthm_key_thmtools_clist
}
\cs_new:Npn \groupthm_new_theorem_from_keys:nn #1 #2
{
\__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_new_theorem:nVVV
{ #2 }
\l__groupthm_key_group_clist
\l__groupthm_name_tl
\l__groupthm_key_thmtools_clist
}
\cs_new:Npn \groupthm_provide_theorem_from_keys:nn #1 #2
{
\__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_provide_theorem:nVVV
{ #2 }
\l__groupthm_key_group_clist
\l__groupthm_name_tl
\l__groupthm_key_thmtools_clist
}
\cs_new:Npn \groupthm_new_theorem_star_from_keys:nn #1 #2
{
\__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_new_theorem_star:nVVV
{ #1 }
\l__groupthm_key_group_clist
\l__groupthm_name_tl
\l__groupthm_key_thmtools_clist
}
\cs_new:Npn \groupthm_provide_theorem_star_from_keys:nn #1 #2
{
\__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_provide_theorem_star:nVVV
{ #1 }
\l__groupthm_key_group_clist
\l__groupthm_name_tl
\l__groupthm_key_thmtools_clist
}
\NewDocumentCommand{\NewGroupedTheorem}{s O{} m}
{
\IfBooleanTF{#1}
{
\groupthm_new_grouped_theorem_star_from_keys:nn { #2 } { #3 }
}
{
\groupthm_new_grouped_theorem_from_keys:nn { #2 } { #3 }
}
}
\ProvideDocumentCommand{\NewGroupedTheorem}{s O{} m}
{
\IfBooleanTF{#1}
{
\groupthm_provide_grouped_theorem_star_from_keys:nn { #2 } { #3 }
}
{
\groupthm_provide_grouped_theorem_from_keys:nn { #2 } { #3 }
}
}
\NewDocumentCommand{\NewTheorem}{s O{} m}
{
\IfBooleanTF{#1}
{
\groupthm_new_theorem_star_from_keys:nn { #2 } { #3 }
}
{
\groupthm_new_theorem_from_keys:nn { #2 } { #3 }
}
}
\ProvideDocumentCommand{\NewTheorem}{s O{} m}
{
\IfBooleanTF{#1}
{
\groupthm_provide_theorem_star_from_keys:nn { #2 } { #3 }
}
{
\groupthm_provide_theorem_from_keys:nn { #2 } { #3 }
}
}
\endinput
%%
%% End of file `groupthm.sty'.