add private wrappers to provide theorems with user pre-specified groups

This commit is contained in:
Maximilian Keßler 2022-01-23 18:36:51 +01:00
parent 5d103708c2
commit f4887160ed

View file

@ -391,6 +391,19 @@
thmtools .clist_set:N = \l_@@_key_thmtools_clist , thmtools .clist_set:N = \l_@@_key_thmtools_clist ,
thmtools .default:n = {} , 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} % \end{macrocode}
% %
% %
@ -469,6 +482,13 @@
% \end{macro} % \end{macro}
% %
% %
%
%
%
% \subsection{Fancy theorems}
%
%
%
% \begin{macro}{\@@_wrap_multiple:nnn} % \begin{macro}{\@@_wrap_multiple:nnn}
% \begin{syntax} % \begin{syntax}
% \cs{@@_wrap_multiple:nnn}\marg{declarator list}\marg{function name}\marg{code} % \cs{@@_wrap_multiple:nnn}\marg{declarator list}\marg{function name}\marg{code}
@ -617,7 +637,9 @@
% \subsection{Provided resources} % \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. % in a flexible way.
% %
% \begin{variable}{star, dagger, big, small, tiny, custom} % \begin{variable}{star, dagger, big, small, tiny, custom}
@ -651,12 +673,86 @@
% It remains to provide a list of theorems at the beginning of the document. % 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} % \begin{macrocode}
\AddToHook { begindocument / before } [ fancythm ] \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} % \end{macrocode}
% %