From f4887160ed61805e1df7e94e52889876dd764830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sun, 23 Jan 2022 18:36:51 +0100 Subject: [PATCH] add private wrappers to provide theorems with user pre-specified groups --- doc/environments/fancythm/fancythm.dtx | 100 ++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 2 deletions(-) diff --git a/doc/environments/fancythm/fancythm.dtx b/doc/environments/fancythm/fancythm.dtx index 8dadf83..d80e269 100644 --- a/doc/environments/fancythm/fancythm.dtx +++ b/doc/environments/fancythm/fancythm.dtx @@ -391,6 +391,19 @@ thmtools .clist_set:N = \l_@@_key_thmtools_clist , thmtools .default:n = {} , } +\keys_define:nn { @@ / providedtheorem } + { + name .tl_set:N = \l_@@_key_name_tl , + name .default:n = \c_novalue_tl , + mdframed .tl_set:N = \l_@@_key_mdframed_tl , + mdframed .default:n = \c_novalue_tl , + style .tl_set:N = \l_@@_key_style_tl , + style .default:n = \c_novalue_tl , + group .clist_set:N = \l_@@_key_group_clist , + group .default:n = {} , + thmtools .clist_set:N = \l_@@_key_thmtools_clist , + thmtools .default:n = {} , + } % \end{macrocode} % % @@ -469,6 +482,13 @@ % \end{macro} % % +% +% +% +% \subsection{Fancy theorems} +% +% +% % \begin{macro}{\@@_wrap_multiple:nnn} % \begin{syntax} % \cs{@@_wrap_multiple:nnn}\marg{declarator list}\marg{function name}\marg{code} @@ -617,7 +637,9 @@ % \subsection{Provided resources} % % -% We introduce various new theorem groups that help us to organize the document +% +% +% We introduce various new 0theorem groups that help us to organize the document % in a flexible way. % % \begin{variable}{star, dagger, big, small, tiny, custom} @@ -650,13 +672,87 @@ % % It remains to provide a list of theorems at the beginning of the document. % +% +% \begin{macro}{\fancythm_add_provided_theorem_to_group:nn} +% +% \begin{macrocode} +\cs_new:Npn \fancythm_add_provided_theorem_to_group:nn #1 #2 + { + \cs_if_exist:cF { @@_provided_theorem__#1__group_clist } + { + \clist_new:c { @@_provided_theorem__#1__group_clist } + } + \clist_put_left:cn { @@_provided_theorem__#1__group_clist } { #2 } + } +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\AddProvidedFancyTheoremToGroup} +% +% +% +% \begin{macrocode} +\NewDocumentCommand { \AddProvidedFancyTheoremToGroup } { m m } + { + \fancythm_add_provided_theorem_to_group:nn { #1 } { #2 } + } +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\@@_provide_package_theorem:nnn} +% \begin{syntax} +% \cs{@@_provide_package_theorem:nnn}\marg{key=value list}\marg{fancy theorem} +% \marg{group} +% \end{syntax} +% +% Group can be one of \texttt{big}, \texttt{small}, \texttt{tiny}, +% and the provided theorem will have this group, unless it conflicts +% with a user-provided group, in which case this is ignored. +% +% +% \begin{macrocode} +\cs_new:Npn \@@_provide_package_theorem:nnn #1 #2 #3 + { + \@@_set_normalized_keys:nn { #1 } { #2 } + \cs_if_exist:cT { @@_provided_theorem__#2__group_clist } + { + \clist_concat:ccc + { l_@@_group_clist } + { @@_provided_theorem__#2__group_clist } + { l_@@_group_clist } + } + \clist_if_in:NnF \l_@@_group_clist { big } + { + \clist_if_in:NnF \l_@@_group_clist { small } + { + \clist_if_in:NnF \l_@@_group_clist { tiny } + { + \clist_put_right:Nn \l_@@_group_clist { #3 } + } + } + } + \fancythm_provide_theorem:nVVV + { #2 } + \l_@@_group_clist + \l_@@_name_tl + \l_@@_thmtools_clist + } +% \end{macrocode} +% \end{macro} +% +% % % % % \begin{macrocode} \AddToHook { begindocument / before } [ fancythm ] { - \ProvideFancyTheorem [ group = big, style = thmgreenmargin ] { example } + \@@_provide_package_theorem:nnn { style = thmgreenmargin } { example } { big } + \@@_provide_package_theorem:nnn { style = thmorangemarginandfill} { lemma } { big } } % \end{macrocode} %