Closed GTM52 closed 1 year ago
The root cause is a long-existing ntheorem
issue, see muzimuzhi/ltx-pkg-ntheorem-issues#1.
Since LaTeX2e 2022-11-01, the inner implementation of \MakeUppercase
(as well as \MakeLowercase
and \MakeTitlecase
) is changed, see latex2e@7447e931
.
\edef\x{\MakeUppercase theorem}
defines \x
which holds \MakeUppercase␣ {t}heorem
\edef\x{\MakeUppercase theorem}
defines \x
which holds \MakeUppercase␣␣␣ []{t}heorem
, noted the []
.The remaining story is similar to muzimuzhi/ltx-pkg-ntheorem-issues#1: at some step ntheorem
's \@begintheorem
will expand to sth containing
\item [... \MakeUppercase []{t}heorem ...]
% which should be
\item[{... \MakeUppercase []{t}heorem ...}]
A partial (because there're other similar \item
uses in ntheorem
) patch for ntheorem
can be found in muzimuzhi/ltx-pkg-ntheorem-issues#1. Below is a possible patch from thmtools
' side (the patch makes use of the knowledge that \thmt@thmname
will be fully expanded by \protected@edef
, hence tricky):
diff --git a/source/thm-kv.dtx b/source/thm-kv.dtx
index 9fb16c4..01c5f79 100644
--- a/source/thm-kv.dtx
+++ b/source/thm-kv.dtx
@@ -373,7 +333,7 @@
\thmt@isnumberedtrue
\thmt@isunlessuniquefalse
\def\thmt@envname{#1}%
- \thmt@setthmname{\thmt@modifycase #1}%
+ \thmt@setthmname{\protect\thmt@modifycase #1}%
% use true code in \thmt@trytwice{<true>}{<false>}
\@thmt@firstkeysettrue
% parse options
\documentclass{article}
\usepackage{ntheorem, thmtools}
\usepackage{xpatch}
\makeatletter
\xpatchcmd\declaretheorem@ii
{\thmt@setthmname{\thmt@modifycase #1}}
{\thmt@setthmname{\protect\thmt@modifycase #1}}
{}{\PatchFailed}
\makeatother
\declaretheorem[style=plain]{theorem}\relax
\begin{document}
\begin{theorem}
This is a theorem.
\end{theorem}
\end{document}
I pushed a fix in another way. Feedbacks welcome.
A revised fix is just pushed and I'm going to release a new version.
\thmt@thmname
has been fully expanded inside \protected@edef
since the first CTAN release of thmtools
in 2008, see
b89ec88
. Hence I decide to not modify this behavior, but only suppress the expansion of \MakeUppercase
/\MakeLowercase
if it is auto prepended to \thmt@thmname
.
It works perfectly, thanks for your help!
thmtools
seems to be incompatible with the packagentheorem
, here is a minimal example:the error message is
Argument of \MakeUppercase has an extra }
. This can be solved by settingtitle = {title_name}
in the command, but it could be uncomfortable when declaring many theorems at the same time.Is there a more elegant way to solve this problem? Thanks for your help.