Open syvshc opened 2 years ago
Analysis
\declaretheorem[numbered=no, thmbox=M, name=Theorem]{theo}
will eventually call (in \thmt@newtheoremiv
)
\newboxtheorem[M]*{theo}{Theorem}
But thmbox
's \newboxtheorem
doesn't support this starred form, hence raises error.
Discussion
I would like to prevent the error and maybe add proper warning messages, but hesitate to make thmbox={<kv-list>}
compatible with numbered=no
and probably other options.
Users are suggested to use thmbox={L, headstyle=...}
in thmtools
, or drop thmtools
and use tcolorbox
. tcolorbox
typesets env contents either in minipage
or in \hbox
, while normal theorem envs simply typeset env contents in a trivlist
. That's the only difference as I can tell.
Misc - thmbox
side
Although thmbox
has options headstyle=<code using #1 and #2>
documented, currently you have to manually double the hashes:
\documentclass{article}
\usepackage{thmbox}
\newboxtheorem[L, headstyle={\bfseries\boldmath####1 ####2}]{theo}{Theorem}
% works
\newboxtheorem[L, headstyle={\bfseries\boldmath#1 #2}]{cor}{Corollary}
% raises error
% ! Illegal parameter number in definition of \thmbox@temp.
\begin{document}
\end{document}
A possible patch to thmbox
:
\usepackage{regexpatch}
\makeatletter
% double the hashes in #1
\xpatchcmd\thmbox@newA
{\def\thmbox@temp##1{#1}}
{\edef\thmbox@temp##1{\unexpanded{#1}}}
{}{\PatchFailed}
\xpatchcmd\thmbox@new
{%
\expandafter\def\csname#2\endcsname{%
\setkeys{thmbox}{#1}%
\@ifnextchar[{\thmbox@beginA{#3}{#4}}{%
\thmbox@begin{#3}{#4}{}}}%
}
{%
\expandafter\edef\csname#2\endcsname{%
% expand #1 (\thmbox@temp) by one-step, then double the hashes
\noexpand\setkeys{thmbox}{\unexpanded\expandafter{#1}}%
\unexpanded{\@ifnextchar[{\thmbox@beginA{#3}{#4}}{%
\thmbox@begin{#3}{#4}{}}}}%
}
{}{\PatchFailed}
\makeatother
I've mailed the above issue to thmbox
's author.
Users are suggested to use
thmbox={L, headstyle=...}
inthmtools
, or dropthmtools
and usetcolorbox
.
Currently, users have to double hashes four times, leading to 16 hashes:
\declaretheorem[thmbox={M, headstyle=\bfseries\boldmath ################1 ################2}, name=Theorem]{theo}
WIth the above thmbox
patch, only four hashes are needed. Still some work to do on thmtools
' side.
Thanks, the problem is solved temporarily. Will there be a compatibility of numbered=no
and thmbox
? Or will there will be a notice of not using numbered
when thmbox
is used?
Will there be a compatibility of
numbered=no
andthmbox
? Or will there will be a notice of not usingnumbered
whenthmbox
is used?
My plan:
numbered=no
and thmbox
are both used, prevent current error and add warning to redirect user to thmbox={...}
\declaretheorem[thmbox={M, headstyle=\bfseries\boldmath #1 #2}, name=Theorem]{theo}
Might not been implemented soon.
WIth the above
thmbox
patch, only four hashes are needed. Still some work to do onthmtools
' side.
% patch \define@key{thmdef}{thmbox}{...}
\xpatchcmd\KV@thmdef@thmbox
{\def\thmt@theoremdefiner{\newboxtheorem[#1]}}
{\edef\thmt@theoremdefiner{\unexpanded{\newboxtheorem[#1]}}}
{}{\PatchFailed}
\xpatchcmd\declaretheorem
{\@ifnextchar}
{\thmt@ifnextchar}
{}{\PatchFailed}
% Compared to \@ifnextchar from kernal, this one uses
% \edef\...{\unexpanded{...}}
% to prevent the number of hash characters reduced to half
\long\def\thmt@ifnextchar#1#2#3{%
\let\reserved@d=#1%
\edef\reserved@a{\unexpanded{#2}}%
\edef\reserved@b{\unexpanded{#3}}%
\futurelet\@let@token\@ifnch}
Side note: \tl_set:Nn
is equivalent to \edef#1{\unexpanded{#2}}
.
as the question mentioned: https://tex.stackexchange.com/questions/222122/problem-with-thmtools-thmbox-and-numbered-no