I want to put a conditional of the form \ifthenelse{\isempty{…}}{…}{…}
in the optional argument of an amsthm
-style theorem. Ordinarily, this works fine, but the package thm-restate
(from thmtools
) seems to break it.
I’ve tried adding brackets, adding \protect
in various places, and so on, but can’t find a way to make this work. Can anyone suggest a way to get around this? A MWE is the following:
\documentclass{article}
\usepackage{xifthen}
\usepackage{amsthm}
\usepackage{thm-restate}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}[\ifthenelse{\isempty{foo}}{bar}{baz}]
\end{theorem}
\end{document}
This gives Undefined control sequence.
on the \isempty
(and several further errors). It compiles fine when thm-restate
is removed.
Replacing \isempty
with the other conditional commands of xifthen
(like \isin
, \isequal
and so on) gives similar errors.
The above example minimally illustrates the error. However, my actual use-case has an extra complication which may be relevant: it’s wrapped into another environment, which passes an argument in to \isempty
. It’s something like the following (which can be appended to the earlier MWE):
\newenvironment{mytheorem}[1][]
{\begin{theorem}[Note\ifthenelse{\isempty{#1}}{}{~arg: #1}]}
{\end{theorem}}
\begin{mytheorem}[foo]
Theorem text.
\end{mytheorem}
So I am really hoping for a solution which works with this not-quite-minimal example also.