# Restating a theorem after the introduction without the optional argument

How do I state a theorem in the first section of my paper with the optional argument, and then restate the theorem in subsequent sections without the optional argument? (The optional argument will contain the number of the section where the proof of the theorem is presented. Prior to the proof I want to restate the theorem without the section number.)

\documentclass{article}
\usepackage{thmtools}
\usepackage{thm-restate}
\newtheorem{thm}{Theorem}

\begin{document}
\section{Introduction}

\begin{restatable}[\S\ref{SectionNumber}]{thm}{TheoremName}
theorem contents
\end{restatable}

\section{Some Section}
\label{SectionNumber}

\TheoremName*

\end{document}


This code outputs the following :

1 Introduction

Theorem 1 (§2) theorem contents

2 Some Section

Theorem 1 (§2) theorem contents

I want “(§2)” to disappear when I restate the theorem.

Note that there is a similar question [Restating a Theorem Without the Optional Argument] with "subsequent sections" replaced by "appendix", but I don't see how to translate the answer to solve my question.

• So every \begin{restatable}[foo]{thm}{thm} ... \end{restatable} should feature the optional argument, but every \thm* call should omit the optional argument? – Dai Bowen Jun 13 '18 at 10:08
• That's right. Marijn has answered my question below. – David Wood Jun 13 '18 at 23:04

The solution in Restating a Theorem Without the Optional Argument can be adapted by changing the check for an appendix to a check if the command is starred or not. The thmtools package internally implements a toggle called \ifthmt@thisistheone. This toggle is true at the definition of the theorem (i.e., when executing the restatable environment), so the conditions (print the optional argument or not) should be reversed compared to the related question. Also the toggle uses \if \else \fi syntax instead of the \IfAppendix{do if true}{do if false} syntax.

MWE:

\documentclass{article}
\usepackage{thmtools}
\usepackage{thm-restate}
\usepackage{xpatch}

\makeatletter
\xpatchcmd{\thmt@restatable}% Edit \thmt@restatable
{\csname #2\@xa\endcsname\ifx\@nx#1\@nx\else[{#1}]\fi}% Replace this code
{\ifthmt@thisistheone\csname #2\@xa\endcsname\ifx\@nx#1\@nx\else[{#1}]\fi\else\csname #2\@xa\endcsname\fi}% with this code
{}{} % execute code for success/failure instances
\makeatother

\newtheorem{thm}{Theorem}

\begin{document}
\section{Introduction}

\begin{restatable}[\S\ref{SectionNumber}]{thm}{TheoremName}
theorem contents
\end{restatable}

\section{Some Section}
\label{SectionNumber}

\TheoremName*

\end{document}


Result: