# Cross-referencing an equation

So far I've always used non-labeled alignments with align*, but I think it's time for a small change. How do I refer to an alignment after creating it? I tried searching similar topics but I didn't find them here. I am using article document class.

Also, does equation behave and work similarly to align? And how would you refer to an equation number (same situation as with align)?

-
You can simple use \begin{align}x+y\label{eq:1}\end{align} and later use \ref{eq:1} or \eqref{eq:1} to reference to the equation. –  Marco Daniel Jun 6 '12 at 11:29
@MarcoDaniel: Thanks! This does the job. –  Thomas E. Jun 6 '12 at 11:36
You can put one label on each line and refer to a particular equation. You can take a look at this pdf link which gives great examples and a documentation of the amsmath package (from which align comes). –  Ger Jun 6 '12 at 11:53
@Ger: Thanks a lot! –  Thomas E. Jun 6 '12 at 12:58
@MarcoDaniel -- even if the output looks the same, if there's only one line to the display, equation is preferable to align. –  barbara beeton Jun 6 '12 at 13:49

Your question is more a general question about labeling and referencing equations.

I think one great introduction is the mathmode of Herbert Voss. It's available at CTAN.

mathmode at CTAN

In the linked document you will find an extra sub section about Labels. It is introduced by:

Every numbered equation can have a label to which a reference is possible.

• There is one restriction for the label names, they cannot include one of LaTeX’s 8 command characters.
• The label names are replaced by the equation number.

Update

The following point was mentioned by Mico:

It may be useful to note that in addition to the eight "basic" special characters that can't be used inside labels, users should also refrain from using

1. commas if the plan on using the cleveref package or
2. any characters that have special meanings for various languages supported by the babel package (such as : in babel/French).

The environment equation doesn't allow any line breaks. So the syntax will be:

$$a^2+b^2=c^2\label{eq:1}$$


The environment align allows line breaks and so every line can get a label.

\begin{align}
x^2+y^2&=2r^2 \label{eq:1} \\
d^2+h^2&=4r^2 \label{eq:2}
\end{align}


To reference to a given label you can use the standard command \ref or any other reference command provided by some packages. I like to use \eqref to reference to equations.

Here a complete example:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$$a^2+b^2=c^2\label{eq:1}$$
Text \eqref{eq:1}
\end{document}

-
Could you please add an alignment point to align? Or use gather for that purpose: I believe that amsmath environment must not be abused, even if the result is similar. Actually your align needs much more work than gather for producing essentially the same output. –  egreg Jun 6 '12 at 12:14
@egreg: I added an alignment point. I don't think that this question needs an introduction to ams environments ;-). Or should I add one? –  Marco Daniel Jun 6 '12 at 12:16
I believe that these comments will suffice. –  egreg Jun 6 '12 at 12:51
Thanks Marco, this was very helpful. –  Thomas E. Jun 6 '12 at 12:59
It may be useful to note that in addition to the eight "basic" special characters that can't be used inside labels, users should also refrain from using (i) commas if the plan on using the cleveref package or (ii) any characters that have special meanings for various languages supported by the babel package (such as : in babel/French). –  Mico Jun 6 '12 at 13:14

For align and equation numbering you might be also interested in using align together with subequations.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{subequations}\label{eq:1}
\begin{align}
a^2+b^2=c^2\label{eq:1a} \\
a^2+b^2=c^2\label{eq:1b}
\end{align}
\end{subequations}
Text \eqref{eq:1}, \eqref{eq:1a}, \eqref{eq:1b}
\end{document}

-
I will try that out:) Thanks. –  Thomas E. Jun 6 '12 at 12:59
If you're willing to use the cleveref package, that coss-referencing command can be stated more succinctly as \cref{eq:1a,eq:1b}, which will generate equations (1.a) and (1.b). –  Mico Jun 6 '12 at 13:22