I am currently stating theorems in the body of my document and then proving them in the appendix (using thmtools). I will currently write something like
\begin{restatable}[Proof in \Cref{whatever}]{lemma}{whatever}
Lemma stuff
\end{restatable}
When I restate the lemma in the appendix, I don't want the optional argument (saying where the proof is) to reappear. Is there a way to get thmtools, or some other package to do this?
Edit: Below I have included a working example
\documentclass{article}
\usepackage{amsthm}
\usepackage{thmtools}
\begin{document}
\newtheorem{lemma}{Lemma}
\begin{restatable}[Proof in Foo]{lemma}{whatever}
Lemma stuff
\end{restatable}
\section{Hmm}
\whatever*
\appendix
\section{Wow}
\whatever*
\end{document}

\IfAppendixis too late and either interferes with the expansion or hides the[so it's not found when expected, I can't really explain it but it seems that using\xpatchcmd{\thmt@restatable}{\csname #2\@xa\endcsname\ifx\@nx#1\@nx\else[{#1}]\fi}{\IfAppendix{\csname #2\@xa\endcsname}{\csname #2\@xa\endcsname\ifx\@nx#1\@nx\else[{#1}]\fi}}{}{}instead seems to work. – Dai Bowen May 11 '17 at 18:08\ifand use that instead of\IfAppendix, I can probably edit this answer to include that case. Otherwise please ask a new question with a proper spec/MWE (and ping me here with a link and I'll take a look). – Dai Bowen Jun 13 '18 at 10:05