19

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...?

1 Answer 1

14

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

4
  • Perfect, I should have thought of that! Thanks! May 10, 2013 at 16:40
  • There may be a problem if you are using \include to compile small pieces of your (large) document. If the definition of \goldbach lies under one usage of include but you reference the theorem, i.e use \goldbach under a different \include. This works against the idea of \include, forcing you to compile the separate \include's simultaneously. Of course, I don't know what would be a reasonable solution to this conundrum. Just leaving a comment highlighting a potential caveat. Jan 4, 2023 at 13:49
  • @LinearChristmas Yes, it cannot work with \include. But how useful is \include nowadays?
    – egreg
    Jan 4, 2023 at 17:22
  • @egreg With my dear computer passing its first non-zero jubilee in base-10, \include is quite useful. :) Compiling 100+ page documents with many packages takes about 1 to 2.5 minutes. Broken into three parts, for instance, around 20 s. Jan 5, 2023 at 23:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .