From 886e562574c779cb28204dc4950b8a22c1fae2cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sun, 16 Jan 2022 18:35:07 +0100 Subject: [PATCH] implement hook rules for theorem groups --- src/environments/groupthm.pysty3 | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/environments/groupthm.pysty3 b/src/environments/groupthm.pysty3 index 7c9b389..e88290d 100644 --- a/src/environments/groupthm.pysty3 +++ b/src/environments/groupthm.pysty3 @@ -54,6 +54,8 @@ __HEADER__(Grouping theorems for easier customization.) \tl_new:N \l_groupthm_mapname_clist \tl_new:N \l_groupthm_thmtools_clist +\tl_new:N \l_groupthm_relation_tl + %%% Keys @@ -160,6 +162,8 @@ __HEADER__(Grouping theorems for easier customization.) \hook_gremove_code:nn { groupthm / thmtools }{*} \clist_map_function:nN { #2 } \group_use:n + +% \ShowHook{ groupthm / postname } \hook_use:n { groupthm / prename } \hook_use:n { groupthm / postname } \hook_use:n { groupthm / mapname } @@ -211,6 +215,32 @@ __HEADER__(Grouping theorems for easier customization.) } +\cs_generate_variant:Nn \hook_gset_rule:nnnn { n n V n } + +% hook group1 relation group2 +\cs_new:Npn \declare_theorem_group_rule:nnnn #1 #2 #3 #4 +{ + \tl_set:Nx \l_groupthm_relation_tl { \tl_trim_spaces:n { #3 } } + + \tl_if_eq:nnT { higher } { #3 } + { + \tl_set:Nn \l_groupthm_relation_tl { after } + } + + \tl_if_eq:nnT { lower } { #3 } + { + \tl_set:Nn \l_groupthm_relation_tl { before } + } + + \hook_gset_rule:nnVn {#1} {#2} \l_groupthm_relation_tl {#4} +} + +% hook, group1, relation, group2 +\NewDocumentCommand { \DeclareTheoremGroupRule } { O{??} m m m } +{ + \declare_theorem_group_rule:nnnn {#1} {#2} {#3} {#4} +} + %%% Default groups available @@ -237,7 +267,7 @@ __HEADER__(Grouping theorems for easier customization.) \NewTheoremGroup [ thmtools = { sibling = insubsection }, - postname = { * } + postname = { * }, ] { star } \NewTheoremGroup