# How to cite a theorem when its order (and thus number) keeps changing

The \begin{theorem} command will automatically order theorems as they appear in the file.

I am currently writing a paper and as I edit the paper the order of the theorems keep changing. However, I have also made references to the theorems in my paper, i.e "the statement follows by theorem 2" for example.

However, now "theorem 2" has become "theorem 6" (again, as an example) and it becomes annoying to search my paper and change this every single time.

How would I automate this? That is, how can I reference a theorem that automatically changes whenever the order changes?

• You should use \labels and \refs (or better, load cleveref and use \cref), to use the cross-referencing capabilities of LaTeX. – Bernard Apr 8 '19 at 23:11

As also @Bernard mentioned, you can simply use \ref and refer to the label you have already defined:

EDIT: The label names are arbitrary. However to avoid confusion, it's recommended to follow a convention LaTeX/Labels and Cross-referencing.

\documentclass{article}
\usepackage{lipsum}
\usepackage{hyperref}
\newtheorem{theorem}{Theorem}

\begin{document}
\section{Introduction}

\begin{theorem}
Let $f$ be a function whose derivative exists in every point, then $f$
is a continuous function.
\label{th:1}
\end{theorem}
Considering Theorem \ref{th:1}, ...

\begin{theorem}
Let $g$ be a function whose derivative exists in every point, then $g$
is a continuous function.
\label{th:2}
\end{theorem}

\begin{theorem}
Let $h$ be a function.
\label{functionh}
\end{theorem}
Considering Theorem \ref{th:1}, \ref{th:2} and \ref{functionh} ...

\end{document}


• I would point out (since the OP probably is unaware of \ref before this) that you can give the labels descriptive names or something (like \label{continuousf} and \ref{continuousf}, \label{thmaboutg} and \ref{thmaboutg}, etc.); you do NOT have to number them in any way or follow any kind of formulaic pattern. – JasonV Apr 9 '19 at 2:22