implement fancy theorem generation

This commit is contained in:
Maximilian Keßler 2022-01-23 16:41:20 +01:00
parent 82b6372e4c
commit 3b16c40e05

View file

@ -55,6 +55,8 @@
% \subsection{Dependencies} % \subsection{Dependencies}
% \begin{macrocode} % \begin{macrocode}
\RequirePackage{l3keys2e} \RequirePackage{l3keys2e}
\RequirePackage{groupthm}
\RequirePackage[default styles]{mkessler-thmstyle}
% \end{macrocode} % \end{macrocode}
% %
% \subsection{Counter management} % \subsection{Counter management}
@ -299,11 +301,53 @@
% \end{macrocode} % \end{macrocode}
% \end{variable} % \end{variable}
% %
%
%
%
% \begin{variable}
% {
% \l_@@_key_name_tl,
% \l_@@_key_mdframed_tl,
% \l_@@_key_style_tl,
% \l_@@_key_group_clist,
% \l_@@_key_thmtools_clist,
% }
%
%
% \begin{macrocode}
\tl_new:N \l_@@_key_name_tl
\tl_new:N \l_@@_key_mdframed_tl
\tl_new:N \l_@@_key_style_tl
\clist_new:N \l_@@_key_group_clist
\clist_new:N \l_@@_key_thmtools_clist
% \end{macrocode}
% \end{variable}
%
%
%
% \begin{variable}
% {
% \l_@@_name_tl,
% \l_@@_thmtools_clist,
% \l_@@_group_clist,
% }
%
%
% \begin{macrocode}
\tl_new:N \l_@@_name_tl
\clist_new:N \l_@@_thmtools_clist
\clist_new:N \l_@@_group_clist
% \end{macrocode}
% \end{variable}
%
% \subsection{Key interface} % \subsection{Key interface}
% %
% \begin{texnote}
% Note that unfortunately, none of the keynames really containes a space. % Note that unfortunately, none of the keynames really containes a space.
% \LaTeX2e strips spaces before loading a package, so introducing them here % \LaTeX2e strips spaces before loading a package, so introducing them here
% would make them inaccessible. % would make them inaccessible.
% Here they are ignored by \LaTeX3 and are present for readability.
% \end{texnote}
% %
% %
% \begin{macrocode} % \begin{macrocode}
@ -329,13 +373,35 @@
% \end{macrocode} % \end{macrocode}
% %
% %
% Process the given keys:
% %
% %
%
%
% \begin{macrocode}
\keys_define:nn { fancythm / fancytheorem }
{
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}
%
%
% Process the given keys:
%
% \begin{macrocode} % \begin{macrocode}
\ProcessKeysOptions{ fancythm } \ProcessKeysOptions{ fancythm }
% \end{macrocode} % \end{macrocode}
% %
%
%
% %
% This sets up translation if requested. % This sets up translation if requested.
% Throughout implementation, we can just use \cs{@@_translate:n} % Throughout implementation, we can just use \cs{@@_translate:n}
@ -352,6 +418,124 @@
\cs_set_eq:NN \@@_translate:n \use:n \cs_set_eq:NN \@@_translate:n \use:n
} }
% \end{macrocode} % \end{macrocode}
%
%
%
%
% \begin{macro}{\@@_set_normalized_keys:nn}
%
% \begin{syntax}
% \cs{@@_set_normalized_keys:nn}\marg{keys}\marg{fallback name}
% \end{syntax}
%
%
% \begin{macrocode}
\cs_new:Npn \@@_set_normalized_keys:nn #1 #2
{
\keys_set:nn { fancythm / fancytheorem } { name, mdframed, style, group, thmtools }
\keys_set:nn { fancythm / fancytheorem } { #1 }
\clist_set_eq:NN \l_@@_group_clist \l_@@_key_group_clist
\clist_set_eq:NN \l_@@_thmtools_clist \l_@@_key_thmtools_clist
\tl_if_eq:NnF \l_@@_key_mdframed_tl { \c_novalue_tl }
{
\clist_put_right:Nx \l_@@_thmtools_clist
{
mdframed = \tl_use:N \l_@@_key_mdframed_tl
}
}
\tl_if_eq:NnF \l_@@_key_style_tl { \c_novalue_tl }
{
\clist_put_right:Nx \l_@@_thmtools_clist
{
style = \tl_use:N \l_@@_key_style_tl
}
}
\tl_if_eq:NnTF \l_@@_key_name_tl { \c_novalue_tl }
{
\tl_set:Nx \l_@@_name_tl
{
\text_titlecase_first:n { \tl_trim_spaces:n { #2 } }
}
}
{
\tl_set_eq:NN \l_@@_name_tl \l_@@_key_name_tl
}
}
% \end{macrocode}
% \end{macro}
%
%
%
%
% \begin{macro}{\fancythm_new_theorem:nnnn}
% \begin{syntax}
% \cs{fancythm_new_theorem:nnnn}\marg{fancy theorem}\marg{groups}
% \marg{name}\marg{thmtools keys}
% \end{syntax}
%
%
%
% \begin{macrocode}
\cs_new:Npn \fancythm_new_theorem:nnnn #1 #2 #3 #4
{
\groupthm_new_family:nnnnn { #1 } { dagger, star } { #3 } { #4 } { #2 }
\groupthm_new_family_options:nnnn
{ #1 }
{ !s !t+ }
{
\IfBooleanT { ##1 }
{
\groupthm_add_theorem_to_group:n { star }
}
\IfBooleanT { ##2 }
{
\groupthm_add_theorem_to_group:n { dagger }
}
}
{ #2 }
}
\cs_generate_variant:Nn \fancythm_new_theorem:nnnn { n V V V }
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\fancythm_new_theorem:nn}
% \begin{syntax}
% \cs{fanythm_new_theorem:nn}\marg{key=value list}\marg{fancy theorem}
% \end{syntax}
%
%
%
% \begin{macrocode}
\cs_new:Npn \fancythm_new_theorem:nn #1 #2
{
\@@_set_normalized_keys:nn { #1 } { #2 }
\fancythm_new_theorem:nVVV
{ #2 }
\l_@@_group_clist
\l_@@_name_tl
\l_@@_thmtools_clist
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\NewFancyTheorem}
% \begin{syntax}
% \cs{NewFancyTheorem}\marg{key=value list}\marg{fancy theorem}
% \end{syntax}
%
%
%
% \begin{macrocode}
\NewDocumentCommand { \NewFancyTheorem } { O{} m }
{
\fancythm_new_theorem:nn { #1 } { #2 }
}
% \end{macrocode}
% \end{macro}
% %
% \begin{macrocode} % \begin{macrocode}
% %