I want to write a macro \createTheorem that creates two environments: a normal one and a "capitalised" one.
For example, \createTheorem{defi}{Definition} will create :
- an environment
\begin{defi}...\end{defi} - and an environment
\begin{Defi}...\end{Defi}.
How would you do that? I would like to know why my code doesn't work.
My code
Here is what I have tried. It doesn't work, the error being
Missing \endcsname inserted. \protect l.13 \documentclass{article}
\usepackage{amsmath}
\newtheorem{theoremForCounter}{theoremForCounter}
\newcommand{\createTheorem}[2]
{
\def\nameNewTheoremCapitalized{\MakeUppercase{#1}}
\newtheorem{#1}[theoremForCounter]{#2}
\newtheorem{\nameNewTheoremCapitalized}[theoremForCounter]{#2}
}
\createTheorem{defi}{Definition}
\begin{document}
\begin{defi}
This is a test.
\end{defi}
\begin{Defi}
This is a test.
\end{Defi}
\end{document}
MakeUppercaseis not expandable (case 2 of my question). And even if it were, it's usually desirable to expand the arguments before passing it to commands (although it isn't necessary in this case). – user202729 Jun 12 '22 at 11:45\expandafterbut it didn't work. Thanks for your interest in my question. – Colas Jun 12 '22 at 11:53\begin/\end{Defi}will have a thicker frame than\begin/\end{defi}. – Colas Jun 13 '22 at 10:02