# \label inside an align environment [closed]

It seems like whenever I use \label{an-label} inside the align environment, and then use to refer to it using \refeq{an-label}, I get the section number instead of the equation number. This does not happen when I use the equation environment.

For example:

\begin{align}
f(x) & = x^2 \label{label1}
\end{align}

Equation \refeq{label1}


would display the section number instead of the equation number. I use mathtools. Is there any reason for this to happen?

When looking in google, it is stated in some web page that \begin{align} \end{align} should be used with the \label{} to name an equation, so I am not sure what I am doing wrong.

-

## closed as too localized by Marco Daniel, Joseph Wright♦Aug 19 '12 at 9:38

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Please provide a minimum example. I cannot reproduce your problem on TeX-Live 2010. – Willie Wong Nov 18 '10 at 22:51
what Willie said - please provide a MWE. I cannot reproduce your problem in MiKTeX 2.8 or MiKTeX 2.9. – Geoffrey Jones Nov 19 '10 at 10:37
The problem might be with \refeq try using \ref or \eqref instead. – Seamus Jan 6 '11 at 12:37
I object to this being closed. I had the same problem and was able to resolve it by looking at an answer here. If the question is only relevant to a few people, how about if everyone else just doesn't read it? Isn't that how you normally operate if a question isn't relevant to you? – j0equ1nn Jan 30 '15 at 4:29

I don't know why you're using the align environment for a single equation instead of the equation environment. Anyway, I've tried this code and it works fine:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\section{Section 1}
\label{sec1}
This is section \ref{sec1}.
\section{Section 2}
\label{sec2}
This is section \ref{sec2}
$$2+2=4$$
$$3+3=6$$
\begin{align}
f(x)&=x^2 \label{ali1}
\end{align}
Take a look at equation \eqref{ali1}.
\end{document}


I've tried using the "mathtools" package instead of "amsmath" but I didn't found any problem... I don't realize what is really happening...

-
+1 to make the Community user happy – Hendrik Vogt Jan 6 '11 at 12:37

I had the same issues like Stefan, however with "gather". Since I found the answer to his issue and also could reproduce the "wrong" referencing, I would like to share my findings with you.

It depends where you put the \label in your equation environment. Working example: In this example, you get the correct label for the one label that you assign to the equations.

\begin{gather}
\arraycolsep=3pt
\medmuskip = 1mu
{^{O}{\dot{\psi}(t)}} = \int^{t}_{0} \frac{{^{O}\V{\tau}_{G,z}}}{{^{B}{J}_{zz}}} dt + {^{O}{\dot{\psi}(t=0)}}, \nonumber \\
{^{O}{\psi(t)}} = \int^{t}_{0} (\int^{t}_{0} \frac{{^{O}\V{\tau}_{G,z}}}{{^{B}{J}_{zz}}} dt + {^{O}{\dot{\psi}(t=0)}}) dt \nonumber \\
\label{calcAngularPosVel} + {^{O}{\psi}(t=0)}, \\
{^{O}{\dot{\psi}(t)}} = {^{B}{\dot{\psi}(t)}}, {^{O}{\psi(t)}} = {^{B}{\psi(t)}}. \nonumber
\end{gather}
\ref{calcAngularPosVel}


Example with "wrong" reference: In this example, you would get the labeling of the section, not for the equation, since the label tries to reference the last line of all equations provided in the gather environment. Hovewer, the last equation line does not provide a label, since the \nonumber command suppresses this. Thus, latex cannot reference to this equation.

\begin{gather}
\arraycolsep=3pt
\medmuskip = 1mu
{^{O}{\dot{\psi}(t)}} = \int^{t}_{0} \frac{{^{O}\V{\tau}_{G,z}}}{{^{B}{J}_{zz}}} dt + {^{O}{\dot{\psi}(t=0)}}, \nonumber \\
{^{O}{\psi(t)}} = \int^{t}_{0} (\int^{t}_{0} \frac{{^{O}\V{\tau}_{G,z}}}{{^{B}{J}_{zz}}} dt + {^{O}{\dot{\psi}(t=0)}}) dt \nonumber \\
+ {^{O}{\psi}(t=0)}, \\
{^{O}{\dot{\psi}(t)}} = {^{B}{\dot{\psi}(t)}}, {^{O}{\psi(t)}} = {^{B}{\psi(t)}}. \nonumber
\label{calcAngularPosVel}
\end{gather}
\ref{calcAngularPosVel}


So it depends where you put the \label command if you want to reference the entire system of equations with only one reference.

Hope this is of help for anyone.

-
I don't think this answers the question, as the OP is using some \refeq command (perhaps from easyeqn) and no \nonumber command, as you do. You should better open a new question and provide a self-answer, if you think others may profit from it, as this one has been closed for a reason. – canaaerus Sep 14 '12 at 5:59
I had the same issue, and this does resolve it: moving the label to within the environment. Apparently it doesn't matter if it's done with \nolabel as above, or with \align with \notag at the end of lines you don't want labeled. Though in the question he already does show the label as within the environment, so it's strange that it still wouldn't work. – j0equ1nn Jan 30 '15 at 4:27