clean up internal package names. not working anymore

This commit is contained in:
Maximilian Keßler 2022-01-16 17:18:11 +01:00
parent 386f07a6d6
commit 0e1a802995

View file

@ -16,29 +16,83 @@ __HEADER__(Grouping theorems for easier customization.)
\newcounter{insection}[section]
\newcounter{insubsection}[subsection]
\tl_new:N \__name_tl
\str_new:N \__name_str
%%% LaTeX3 Wrappers around external commands
\cs_new:Nn \declaretheorem:nn
{
\declaretheorem [ #1 ] { #2 }
\declaretheorem [ #2 ] { #1 }
}
\cs_generate_variant:Nn \declaretheorem:nn { n V }
%%% Messages
\msg_new:nnn { groupthm } { unknown ~ key }
{
\msg_error_text:n { groupthm } Unknown key #1 supplied \msg_line_context:
}
\cs_generate_variant:Nn \declaretheorem:nn {V V, V n}
\msg_new:nnn { groupthm } { unknown ~ group }
{
\msg_error_text:n { groupthm} Unknown group #1 supplied \msg_line_context:
}
%%% Variables
\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
\tl_new:N \l_groupthm_mapname_clist
\tl_new:N \l_groupthm_thmtools_clist
%%% Keys
\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 = \c_empty_clist,
group .groups:n = { groupedtheorem },
mapname .clist_set:N = \l_groupthm_mapname_clist,
mapname .default:n = \c_empty_clist,
mapname .groups:n = { theoremgroup },
thmtools .clist_set:N = \l_groupthm_thmtools_clist,
thmtools .default:n = \c_empty_clist,
thmtools .groups:n = { theoremgroup, groupedtheorem, theoremvariants }
}
% groupname, prename, postname, mapname, thmtools
\cs_new:Npn \store_group:nnnnn #1#2#3#4#5
\cs_new:Npn \new_theorem_group:nnnnn #1#2#3#4#5
{
\cs_new:cpn { retrieve_group_#1: }
\cs_new:cpn { group_use_#1: }
{
\AddToHook { groupthm / prename } [ #1 ]
{
\tl_put_left:Nx \__name_tl { #2 }
\tl_put_left:Nx \l_groupthm_prename_tl { #2 }
}
\AddToHook { groupthm / postname } [ #1 ]
{
\tl_put_right:Nx \__name_tl { #3 }
\tl_put_right:Nx \l_groupthm_postname_tl { #3 }
}
\AddToHook { groupthm / mapname } [ #1 ]
{
@ -46,106 +100,106 @@ __HEADER__(Grouping theorems for easier customization.)
}
\AddToHook { groupthm / thmtools } [ #1 ]
{
\clist_put_right:Nn __PACKAGE_MACRO__(thmtools_args_clist) { #5 }
\clist_put_right:Nn \l_groupthm_thmtools_clist) { #5 }
}
}
}
\cs_generate_variant:Nn \new_theorem_group:nnnnn { n V V V V }
\cs_new:Npn \retrieve_group:n #1
\cs_new:Npn \new_theorem_group_by_keys:nn #1#2
{
\use:c { retrieve_group_#1: }
}
\cs_generate_variant:Nn \store_group:nnnnn { n V V V V }
\keys_define:nn { groupthm / theoremgroup }
{
prename .tl_set:N = \l_groupthm_prename_tl,
prename .default:n = \c_empty_tl,
postname .tl_set:N = \l_groupthm_postname_tl,
postname .default:n = \c_empty_tl,
mapname .clist_set:N = \l_groupthm_mapname_clist,
mapname .default:n = \c_empty_clist,
thmtools .clist_set:N = \l_groupthm_thmtools_clist,
thmtools .default:n = \c_empty_clist
}
\NewDocumentCommand{\NewTheoremGroup}{ m o }
{
\keys_set:nn { groupthm / theoremgroup } { postname, prename, mapname, thmtools }
\IfValueT {#2}
{
\keys_set:nn { groupthm / theoremgroup } { #2 }
}
\store_group:nVVVV { #1 }
\l_groupthm_prename_tl
\l_groupthm_postname_tl
\keys_set_groups:nnn { groupthm } { theoremgroup } { prename, postname, mapname, thmtools }
\keys_set_groups:nnn { groupthm } { theoremgroup } { #2 }
\new_theorem_group:nVVVV { #1 }
\l_groupthm_key_prename_tl
\l_groupthm_key_postname_tl
\l_groupthm_mapname_clist
\l_groupthm_thmtools_clist
}
\keys_define:nn { groupthm / groupedtheorem }
\NewDocumentCommand{\NewTheoremGroup}{ O{} m }
{
thmtools .clist_set:N = __PACKAGE_MACRO__(thmtools_args_clist),
thmtools .default:n = {},
group .clist_set:N = __PACKAGE_MACRO__(groups_clist),
group .default:n = {},
name .tl_set:N = __PACKAGE_MACRO__(theorem_name_tl),
name .default:n = \c_novalue_tl
\new_theorem_group_by_keys:nn { #2 } { #1 }
}
\NewDocumentCommand{\NewGroupedTheorem}{o m}
%%% Grouped Theorems
\cs_new:Npn \group_use:n #1
{
\keys_set:nn { groupthm / groupedtheorem } { name, group, thmtools }
\IfValueT {#1}
\cs_if_exist_use:cF { group_use_#1: }
{
\keys_set:nn { groupthm / groupedtheorem } { #1 }
}
\msg_error:nnn { groupthm } { unknown ~ group }
}
}
% Construct name
\tl_if_eq:NnTF __PACKAGE_MACRO__(theorem_name_tl) { \c_novalue_tl }
{
\str_set:Nx \__name_str
{
\text_titlecase_first:n {#2}
}
}
{
\str_set:Nx \__name_str
{
\tl_use:N __PACKAGE_MACRO__(theorem_name_tl)
}
}
% envname, groups, name, thmtools
\cs_new:Npn \new_grouped_theorem: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_set:Nn \l_groupthm_thmtools_clist { #4 }
\tl_set:NV \__name_tl \__name_str
% Process groups here, adding to the hooks for prename, postname, mapname, thmtools
% mapname currently not implemented
\RemoveFromHook { groupthm / prename }[ * ]
\RemoveFromHook { groupthm / prename }[*]
\RemoveFromHook { groupthm / postname }[*]
\RemoveFromHook { groupthm / mapname }[*]
\RemoveFromHook { groupthm / mapname }[*]
\RemoveFromHook { groupthm / thmtools }[*]
\clist_map_function:NN __PACKAGE_MACRO__(groups_clist) \retrieve_group:n
%\clist_show:N __PACKAGE_MACRO__(groups_clist)
\clist_map_function:nN { #1 } \group_use:n
\hook_use:n { groupthm / prename }
\hook_use:n { groupthm / postname }
\hook_use:n { groupthm / mapname }
\hook_use:n { groupthm / thmtools }
\clist_put_right:Nx __PACKAGE_MACRO__(thmtools_args_clist)
\clist_put_right:Nx \l_groupthm_thmtools_tl
{
name = \str_use:N \__name_tl
name = \tl_use:N \l_groupthm_prename_tl
\tl_use:N \l_groupthm_name_tl
\tl_use:N \l_groupthm_postname_tl
}
\declaretheorem:Vn
{
__PACKAGE_MACRO__(thmtools_args_clist)
\l_groupthm_thmtools_clist
}
{ #2 }
}
\cs_generate_variant:Nn \new_grouped_theorem:nnnn { n V V V }
% envname, keys
\cs_new:Npn \new_grouped_theorem_from_keys:nn #1 #2
{
\keys_set_groups:nnn { groupthm } { groupedtheorem } { name, group, thmtools }
\keys_set_groups:nnn { groupthm } { groupedtheorem } { #1 }
% Construct name
\tl_if_eq:NnTF \l_groupthm_key_name_tl { \c_novalue_tl }
{
\tl_set:Nx \l_groupthm_name_tl
{
\text_titlecase_first:n {#2}
}
}
{
\tl_set_eq:NN \l_groupthm_name_tl \l_groupthm_key_name_tl
}
\new_grouped_theorem:nVVV
{ #1 }
\l_groupthm_key_group_clist
\l_groupthm_name_tl
\l_groupthm_key_thmtools_clist
}
\NewDocumentCommand{\NewGroupedTheorem}{O{} m}
{
\new_grouped_theorem_from_keys:nn { #2 } { #1 }
}
%%% Default groups available
@ -174,8 +228,3 @@ __HEADER__(Grouping theorems for easier customization.)
thmtools = { sibling = insubsection },
postname = { * }
]
\NewTheoremGroup { starred }
[
thmtools = { numbered = no }
]