I'm trying to add a reference (with optional argument) in the theorem note. Below is a MWE.
\documentclass{article}
\usepackage[french]{babel}
\usepackage{amsthm,create-theorem}
\CreateTheorem{theorem,corollary}{}
\begin{document}
\begin{theorem}\label{thm}
\end{theorem}
\begin{corollary}[{\crefthe[de]{thm}}]
\end{corollary}
\end{document}
However, I'm getting the following errors:
Argument of \crefthe has an extra }.
<inserted text>
\par
Paragraph ended before \crefthe was complete.
<to be read again>
\par
Since the \crefthe[de]{thm} has already been put into an extra group, I'd expect the optional argument to work normally here, except that it doesn't... I suspect that the problem is in the package create-theorem, when I misused some e or x-type expansions, but when defining the environments I was using the n-type (line 982 in version 2022-08-08 of create-theorem):
\NewDocumentEnvironment { #1 } { O{} }
{
\tl_if_blank:nTF { ##1 }
...
Since the error message says very few where the actual problem might be, I don't know what to do next to locate the exact line that is causing these errors.
May I ask what is causing the errors here, and how should I fix it?
Add: as @daleif noted in the comment, one can use double braces here. However, if one defines the theorems directly via amsthm, then single braces suffice:
\documentclass{article}
\usepackage[french]{babel}
% \usepackage{amsthm,create-theorem}
% \CreateTheorem{theorem,corollary}{}
\usepackage{amsthm}
\newtheorem{theorem}{Théorème}
\newtheorem{corollary}{Corollaire}
\usepackage{crefthe}
\crefthename{theorem}[le]{théorème}[les]{théorèmes}
\begin{document}
\begin{theorem}\label{thm}
\end{theorem}
\begin{corollary}[{\crefthe[de]{thm}}]
\end{corollary}
\end{document}
Thus something must be wrong with create-theorem, but unfortunately I have no idea how to find it...
create-theorem, since single braces works when one defines the environments directly withamsthm.) – Jinwen Aug 11 '22 at 15:01:p– Jinwen Aug 11 '22 at 15:05