latex-packages/doc/environments/groupthm/groupthm.sty

1024 lines
32 KiB
TeX

%%
%% 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
{
\tl_log:n { Declaring ~ thmtools ~ theorem ~ #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.
}
\msg_new:nnn { groupthm } { misuse ~ add ~ theorem ~ to ~ group }
{
Bad ~ usage ~ of ~ 'AddTheoremToGroup' ~ macro ~ outside ~ theorem ~
family ~ options ~ \msg_line_context:
}
\msg_new:nnnn { groupthm } { undefined ~ theorem ~ variant }
{
Bad ~ call ~ of ~ theorem ~ variant ~ of ~ '#1' ~ \msg_line_context:
}
{
You ~ wanted ~ to ~ call ~ the ~ variant ~ with ~ group(s) ~
'#2' ~ of ~ theorem ~ family ~ '#1', ~ but ~ it ~ has ~ not ~ been ~
generated ~ yet. ~
Probably ~ you ~ forgot ~ this. ~
\msg_see_documentation_text:n { groupthm }
}
\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
\bool_new:N \l__groupthm_in_family_options_environment_bool
\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 \__groupthm_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_generate_variant:Nn \groupthm_new_grouped_theorem:nnnn { x V n n }
\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 }
}
}
\cs_new:Npn \__groupthm_declare_grouped_theorem_family_aux:nnnnnn #1 #2 #3 #4 #5 #6
{
\clist_set:Nn \l_tmpa_clist { #2 }
\powerset_clist_foreach:Nn \l_tmpa_clist
{
\clist_set_eq:NN \l__groupthm_group_clist \l_tmpa_clist
\clist_put_right:Nn \l__groupthm_group_clist { #5 }
\__groupthm_sort_theorem_group_names:
\use:c{groupthm_#6_grouped_theorem:xVnn}
{__#1__groups_\clist_use:Nn \l__groupthm_group_clist {_}}
\l__groupthm_group_clist
{ #3 }
{ #4 }
}
}
\cs_new:Npn \groupthm_new_grouped_theorem_family:nnnn #1 #2 #3 #4
{
\__groupthm_declare_grouped_theorem_family_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { } { new }
}
\cs_generate_variant:Nn \groupthm_new_grouped_theorem_family:nnnn { n V V V }
\cs_new:Npn \groupthm_provide_grouped_theorem_family:nnnn #1 #2 #3 #4
{
\__groupthm_declare_grouped_theorem_family_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { } { provide }
}
\cs_generate_variant:Nn \groupthm_provide_grouped_theorem_family:nnnn { n V V V }
\cs_new:Npn \groupthm_new_grouped_theorem_family_star:nnnn #1 #2 #3 #4
{
\__groupthm_declare_grouped_theorem_family_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { unnumbered } { new }
}
\cs_generate_variant:Nn \groupthm_new_grouped_theorem_family_star:nnnn { n V V V }
\cs_new:Npn \groupthm_provide_grouped_theorem_family_star:nnnn #1 #2 #3 #4
{
\__groupthm_declare_grouped_theorem_family_aux:nnnnnn
{ #1 } { #2 } { #3 } { #4 } { } { provide }
}
\cs_generate_variant:Nn \groupthm_provide_grouped_theorem_family_star:nnnn { n V V V }
\cs_new:Npn \groupthm_new_theorem_family:nnnn #1 #2 #3 #4
{
\__groupthm_declare_grouped_theorem_family_aux:nnnnnn
{ #1 } { #2, starred } { #3 } { #4 } { } { new }
}
\cs_generate_variant:Nn \groupthm_new_theorem_family:nnnn { n V V V }
\cs_new:Npn \groupthm_provide_theorem_family:nnnn #1 #2 #3 #4
{
\__groupthm_declare_grouped_theorem_family_aux:nnnnnn
{ #1 } { #2, starred } { #3 } { #4 } { } { provide }
}
\cs_generate_variant:Nn \groupthm_provide_theorem_family:nnnn { n V V V }
\cs_new:Npn \groupthm_new_theorem_family_star:nnnn #1 #2 #3 #4
{
\__groupthm_declare_grouped_theorem_family_aux:nnnnnn
{ #1 } { #2, starred } { #3 } { #4 } { unnumbered } { new }
}
\cs_generate_variant:Nn \groupthm_new_theorem_family_star:nnnn { n V V V }
\cs_new:Npn \groupthm_provide_theorem_family_star:nnnn #1 #2 #3 #4
{
\__groupthm_declare_grouped_theorem_family_aux:nnnnnn
{ #1 } { #2, starred } { #3 } { #4 } { } { provide }
}
\cs_generate_variant:Nn \groupthm_provide_theorem_family_star:nnnn { n V V V }
\cs_new:Npn \groupthm_new_grouped_theorem_family_from_keys:nn #1 #2
{
\__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_new_grouped_theorem_family:nVVV
{ #2 }
\l__groupthm_group_clist
\l__groupthm_name_tl
\l__groupthm_thmtools_clist
}
\cs_new:Npn \groupthm_provide_grouped_theorem_family_from_keys:nn #1 #2
{
\__groupthm_set_normalized_keys:nnn { #1 } {groupedtheorem} { #2 }
\groupthm_provide_grouped_theorem_family:nVVV
{ #2 }
\l__groupthm_group_clist
\l__groupthm_name_tl
\l__groupthm_thmtools_clist
}
\cs_new:Npn \groupthm_new_grouped_theorem_family_star_from_keys:nn #1 #2
{
\__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem }{ #2 }
\groupthm_new_grouped_theorem_family_star:nVVV
{ #2 }
\l__groupthm_group_clist
\l__groupthm_name_tl
\l__groupthm_thmtools_clist
}
\cs_new:Npn \groupthm_provide_grouped_theorem_family_star_from_keys:nn #1 #2
{
\__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem }{ #2 }
\groupthm_provide_grouped_theorem_family_star:nVVV
{ #2 }
\l__groupthm_group_clist
\l__groupthm_name_tl
\l__groupthm_thmtools_clist
}
\cs_new:Npn \groupthm_new_theorem_family_from_keys:nn #1 #2
{
\__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_new_theorem_family:nVVV
{ #2 }
\l__groupthm_group_clist
\l__groupthm_name_tl
\l__groupthm_thmtools_clist
}
\cs_new:Npn \groupthm_provide_theorem_family_from_keys:nn #1 #2
{
\__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_provide_theorem_family:nVVV
{ #2 }
\l__groupthm_group_clist
\l__groupthm_name_tl
\l__groupthm_thmtools_clist
}
\cs_new:Npn \groupthm_new_theorem_family_star_from_keys:nn #1 #2
{
\__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_new_theorem_family_star:nVVV
{ #2 }
\l__groupthm_group_clist
\l__groupthm_name_tl
\l__groupthm_thmtools_clist
}
\cs_new:Npn \groupthm_provide_theorem_family_star_from_keys:nn #1 #2
{
\__groupthm_set_normalized_keys:nnn { #1 } { groupedtheorem } { #2 }
\groupthm_provide_theorem_family_star:nVVV
{ #2 }
\l__groupthm_group_clist
\l__groupthm_name_tl
\l__groupthm_thmtools_clist
}
\NewDocumentCommand{\NewGroupedTheoremFamily}{s O{} m}
{
\IfBooleanTF { #1 }
{
\groupthm_new_grouped_theorem_family_star_from_keys:nn { #2 } { #3 }
}
{
\groupthm_new_grouped_theorem_family_from_keys:nn { #2 } { #3 }
}
}
\NewDocumentCommand{\ProvideGroupedTheoremFamily}{s O{} m}
{
\IfBooleanTF { #1 }
{
\groupthm_provide_grouped_theorem_family_star_from_keys:nn { #2 } { #3 }
}
{
\groupthm_provide_grouped_theorem_family_from_keys:nn { #2 } { #3 }
}
}
\NewDocumentCommand{\NewTheoremFamily}{s O{} m}
{
\IfBooleanTF { #1 }
{
\groupthm_new_theorem_family_star_from_keys:nn { #2 } { #3 }
}
{
\groupthm_new_theorem_family_from_keys:nn { #2 } { #3 }
}
}
\NewDocumentCommand{\ProvideTheoremFamily}{s O{} m}
{
\IfBooleanTF { #1 }
{
\groupthm_provide_theorem_family_star_from_keys:nn { #2 } { #3 }
}
{
\groupthm_provide_theorem_family_from_keys:nn { #2 } { #3 }
}
}
\cs_new:Npn \groupthm_add_theorem_to_group:n #1
{
\bool_if:NTF \l__groupthm_in_family_options_environment_bool
{
\clist_put_left:Nn \l__groupthm_group_clist { #1 }
}
{
\msg_error:nn { groupthm } { misuse ~ add ~ theorem ~ to ~ group }
}
}
\NewDocumentCommand { \AddTheoremToGroup } { m }
{
\groupthm_add_theorem_to_group:n { #1 }
}
\cs_new:Npn \__groupthm_declare_theorem_family_options_aux:nnnnn #1 #2 #3 #4 #5
{
\use:c{ #5 DocumentEnvironment }
{ #1 }
{ #2 }
{
\clist_clear:N \l__groupthm_group_clist
\bool_set_true:N \l__groupthm_in_family_options_environment_bool
#3
\bool_set_false:N \l__groupthm_in_family_options_environment_bool
\clist_put_right:Nn \l__groupthm_group_clist { #4 }
\__groupthm_sort_theorem_group_names:
\cs_if_exist:cTF { __#1__groups_ \clist_use:Nn \l__groupthm_group_clist { _ } }
{
\begin { __#1__groups_ \clist_use:Nn \l__groupthm_group_clist { _ } }
}
{
\msg_error:nnxx { groupthm } { undefined ~ theorem ~ variant }
{ #1 }
{ \clist_use:Nnnn \l__groupthm_group_clist { ~ and ~ } {, ~} { , ~ and ~ } }
}
}
{
\clist_clear:N \l__groupthm_group_clist
\bool_set_true:N \l__groupthm_in_family_options_environment_bool
#3
\bool_set_false:N \l__groupthm_in_family_options_environment_bool
\clist_put_right:Nn \l__groupthm_group_clist { #4 }
\__groupthm_sort_theorem_group_names:
\end { __#1__groups_ \clist_use:Nn \l__groupthm_group_clist { _ } }
}
}
\cs_new:Npn \groupthm_new_grouped_theorem_family_options:nnn #1 #2 #3
{
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { New }
}
\cs_new:Npn \groupthm_renew_grouped_theorem_family_options:nnn #1 #2 #3
{
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Renew }
}
\cs_new:Npn \groupthm_provide_grouped_theorem_family_options:nnn #1 #2 #3
{
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Provide }
}
\cs_new:Npn \groupthm_declare_grouped_theorem_family_options:nnn #1 #2 #3
{
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Declare }
}
\cs_new:Npn \groupthm_new_theorem_family_options:nnn #1 #2 #3
{
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { New }
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1* } { #2 } { #3 } { starred } { New }
}
\cs_new:Npn \groupthm_renew_theorem_family_options:nnn #1 #2 #3
{
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Renew }
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1* } { #2 } { #3 } { starred } { Renew }
}
\cs_new:Npn \groupthm_provide_theorem_family_options:nnn #1 #2 #3
{
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Provide }
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1* } { #2 } { #3 } { starred } { Provide }
}
\cs_new:Npn \groupthm_declare_theorem_family_options:nnn #1 #2 #3
{
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1 } { #2 } { #3 } { } { Declare }
\__groupthm_declare_theorem_family_options_aux:nnnnn
{ #1* } { #2 } { #3 } { starred } { Declare }
}
\NewDocumentCommand { \NewGroupedTheoremFamilyOptions } { s m m m }
{
\IfBooleanTF { #1 }
{
\groupthm_new_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_new_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
\NewDocumentCommand { \RenewGroupedTheoremFamilyOptions } { s m m m }
{
\IfBooleanTF { #1 }
{
\groupthm_renew_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_renew_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
\NewDocumentCommand { \ProvideGroupedTheoremFamilyOptions } { s m m m }
{
\IfBooleanTF { #1 }
{
\groupthm_provide_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_provide_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
\NewDocumentCommand { \DeclareGroupedTheoremFamilyOptions } { s m m m }
{
\IfBooleanTF { #1 }
{
\groupthm_declare_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_declare_grouped_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
\NewDocumentCommand { \NewTheoremFamilyOptions } { s m m m }
{
\IfBooleanTF { #1 }
{
\groupthm_new_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_new_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
\NewDocumentCommand { \RenewTheoremFamilyOptions } { s m m m }
{
\IfBooleanTF { #1 }
{
\groupthm_renew_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_renew_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
\NewDocumentCommand { \ProvideTheoremFamilyOptions } { s m m m }
{
\IfBooleanTF { #1 }
{
\groupthm_provide_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_provide_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
\NewDocumentCommand { \DeclareTheoremFamilyOptions } { s m m m }
{
\IfBooleanTF { #1 }
{
\groupthm_declare_theorem_family_options:nnn
{ #2 }
{ #3 }
{
#4
\groupthm_add_theorem_to_group:n { unnumbered }
}
}
{
\groupthm_declare_theorem_family_options:nnn
{ #2 }
{ #3 }
{ #4 }
}
}
\endinput
%%
%% End of file `groupthm.sty'.