[Tex/LaTex] using a restatable before it is stated

cross-referencingtheoremsthmtools

This question is related to the question at Recalling a theorem, which uses the thmtools and thm-restate packages and the restatable environment to define a theorem that can be re-stated later on.

Is it possible to refer to something that is defined later on?
In an earlier chapter, I have some discussion that is referring to a definition that is defined properly in a later chapter, but I can't reuse the definition before it is defined…

For example, when I do the following

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

\declaretheorem[name=Theorem,numberwithin=section]{thm}

\begin{document}

\section{First}

\goldbach*

\begin{restatable}[Goldbach's conjecture]{thm}{goldbach}
\label{thm:goldbach}
Every even integer greater than 2 can be expressed as the sum of two primes.
\end{restatable}

\end{document} 

I get an error –

undefined control sequence \goldbach

Is there any way to export these definitions so that they can be referred to before they are actually defined…?

Best Answer

Do it the other way round, using the restatable* environment.

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

\declaretheorem[name=Theorem,numberwithin=section]{thm}

\begin{document}

\section{First}

\begin{restatable*}[Goldbach's conjecture]{thm}{goldbach}
\label{thm:goldbach}
Every even integer greater than 2 can be expressed as the sum of two primes.
\end{restatable*}

\lipsum[2]

\begin{thm}
One
\end{thm}

\lipsum[3]

\begin{thm}
Two
\end{thm}

\lipsum[3]

\goldbach

\lipsum[3]


\end{document} 

enter image description here

Related Question