start development of groupthm package

This commit is contained in:
Maximilian Keßler 2022-01-16 12:12:12 +01:00
parent 09d10fba30
commit 274ce257d6

View file

@ -0,0 +1,80 @@
__HEADER__(Grouping theorems for easier customization.)
\ExplSyntaxOn
\RequirePackage{amsthm}
\RequirePackage{thmtools}
\cs_new:Nn \declaretheorem:nn
{
\declaretheorem [ #1 ] { #2 }
}
\cs_generate_variant:Nn \declaretheorem:nn {V V}
\keys_define:nn { groupthm / theoremgroup }
{
postname .tl_set:N = \l_groupthm_postname_tl,
prename .tl_set:N = \l_groupthm_prename_tl,
mapname .tl_set:N = \l_groupthm_mapname_tl,
thmtools .tl_set:N = \l_groupthm_thmtools_tl
}
\clist_new:N __PACKAGE_MACRO__(thmtools_args)
\keys_define:nn { groupthm / groupedtheorem }
{
thmtools .clist_set:N = __PACKAGE_MACRO__(thmtools_args_clist),
group .clist_set:N = __PACKAGE_MACRO__(groups_clist),
name .tl_set:N = __PACKAGE_MACRO__(theorem_name_tl),
name .default:n = \q_no_value
}
\NewDocumentCommand{\NewGroupedTheorem}{o m}
{
\keys_set:nn { groupthm / groupedtheorem } { #1 }
\RemoveFromHook
\UseHook
% Construct name
\str_new:N \__name_str
\str_set:Nx \__name_str
{
\quark_if_no_value:NTF __PACKAGE_MACRO__(theorem_name_tl)
{
\text_titlecase_first:n {#2}
}
{
\tl_use:N __PACKAGE_MACRO__(theorem_name_tl)
}
}
% Process groups here, adding to the hooks for prename, postname, mapname, thmtools
% mapname currently not implemented
% \clist_new:N __PACKAGE_MACRO__(mapname_clist)
% \clist_set:N
\str_put_left:Nx \__name_str
{
\UseHook { groupthm / prename }
}
\str_put_right:Nx \__name_str
{
\UseHook { groupthm / postname }
}
\declaretheorem:VV
{
__PACKAGE_MACRO__(thmtools_args_clist)
}
{ \__name_str }
}
\cs_new: