Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
2  
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
1  
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
add comment

2 Answers

up vote 6 down vote accepted

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:

\begin{equation}
 a^2+b^2=c^2\label{eq:1}
\end{equation}

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}
\begin{equation}
 a^2+b^2=c^2\label{eq:1}
\end{equation}
Text \eqref{eq:1}
\end{document}
share|improve this answer
2  
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
show 3 more comments

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}
share|improve this answer
    
I will try that out:) Thanks. –  Thomas E. Jun 6 '12 at 12:59
1  
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.