# Referring to theorems

I have the following: I have a lemma whose "number" as of yet is not certain (right now it's Lemma 0.1), and then a theorem in which I wish to refer to this lemma X, "let such and such be as in Lemma X". I could write "...as in Lemma 0.1" and change it once I'm done with the thesis, but is there a way to refer to lemma 0.1 so that if (when) it becomes, say, lemma 5.2, so that when this changes, my reference in the theorem also changes?

Wonderful wording, hope you get the point :P

• Looks like you're looking for \label{lem:amazingLemma} and \ref{lem:amazingLemma}. – Loop Space Jul 17 '13 at 13:26
• @Andrew Yes! So how do I use it, i.e. where do I put it? \begin{lemma} yadayada \end{lemma} – Erik Vesterlund Jul 17 '13 at 13:28
• By the way: the same scheme of \label and \ref can and should be applied not only to theorems, but also to tables, figures, listings, chapters, sections ... virtually anything which is numbered (automatically). You will do yourself a favour, if you do all references in your thesis in this way right from the beginning :-) – Thomas F. Sturm Jul 17 '13 at 14:44

For fuller details, take a look in some form of LaTeX documentation, for example Section 2.8 of the Not so short guide to LaTeX2e.

Here's an example of use:

In Lemma~\ref{lem:amazingLemma} we will prove something amazing.

\begin{lemma}
\label{lem:amazingLemma}
This is amazing.
\end{lemma}

\begin{theorem}
Under the conditions of Lemma~\ref{lem:amazingLemma} then things are amazing.
\end{theorem}


Important points:

1. You can refer to a label before or after it is defined, but it may take two compilations for LaTeX to get all the numbers straight.
2. The \label command has to go inside the environment, otherwise it will pick up something else (probably the last section declaration).
3. There are a variety of packages that enhance the cross-referencing system, for example making it so that your reference remembers whether it was a Lemma or a Proposition. If you look at the links under the "Related" column on the right-hand side of this page you'll get a feeling for what is possible with cross-referencing.
4. Just about anything with a counter can be labelled in this way.
• if equations are numbered (and labeled), and amsmath is being used, \eqref will automatically put parentheses around the number (and keep the whole thing upright in italic, e.g., theorem environments). – barbara beeton Jul 17 '13 at 16:08

Here's a working example:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{amsmath}

\newtheorem{lemma}{Lemma}
\newtheorem{theorem}{Theorem}

\begin{document}

\begin{lemma}
\label{LeftCosetsDisjoint}
Let $H$ be a subgroup of a group $G$, and let $x$ and $y$ be
elements of $G$.  Suppose that $xH \cap yH$ is non-empty.
Then $xH = yH$.
\end{lemma}

\begin{theorem}
\label{MyTheorem}
Let such and such be as in Lemma \ref{LeftCosetsDisjoint}
\end{theorem}

\end{document}

• I only get (??) for the call to \ref{LeftCosetsDisjoint}. Also, which packages are absolutely necessary for this to work - seems there are several being imported. Thanks – Relative0 Apr 21 '14 at 17:52
• @user1922184 Did you build twice? Whenever you create a new label you need to typeset (or build) twice, i.e. run pdflatex twice. – remus Apr 22 '14 at 6:49

You have to label the destination to which you want to point with (in the corresponding line/block)

\label{name}


and then refer to it with

\ref{name}


It is usually a good idea to add some sort of specifier to the name (as Andrew Stacey did in his comment) - some examples are here in the introduction: http://en.wikibooks.org/wiki/LaTeX/Labels_and_Cross-referencing

I use different macros for every type (e.g. \imgref{...} and \eqref{...}) - makes stuff simpler in the long term (as bracket-type/color/... can be changed easily from one location.

Example:

\documentclass{article}
\usepackage{amssymb}
\newcommand{\eqRef}{(\ref{eq:#1})}
\begin{document}
\begin{equation}
1 + 1 = 2\label{eq:calc}
\end{equation}
Some serious calculation was done in \eqRef{calc}
\end{document}

• Note that \eqref is already defined in amsmath so this particular choice of name has potential for a clash. – Loop Space Jul 17 '13 at 13:36