89

The following LaTeX document:

\documentclass{article}

\usepackage{amsmath}
\begin{document}
\begin{align}
  E=mc^2 \\ \nonumber
  E=mc^2 \label{eq1}
\end{align}

ref \ref{eq1}
\end{document}

Does not display the reference \ref{eq1}. Why?

Alan Munn
  • 218,180
Yotam
  • 7,109

4 Answers4

103

The \label is on the same equation line (not code line) as the \nonumber and therefore doesn't get any equation number to label and to reference later. You need to move \nonumber (or the \label) before the \\:

\documentclass{article}

\usepackage{amsmath}
\begin{document}
\begin{align}
  E=mc^2 \nonumber \\
  E=mc^2 \label{eq1}
\end{align}

ref \ref{eq1}
\end{document}

In the above case the equation number is placed in the second row. If you want it in the first then place the \nonumber after the \\ but the \label before it.

David Carlisle
  • 757,742
Martin Scharrer
  • 262,582
16

use it this way:

\begin{align}
  E=mc^2 \nonumber\\ 
  E=mc^2 \label{eq1}
\end{align}

ref \ref{eq1}

Set \nonumber before the double backslash

5

For posterity: I solved this problem by commenting out the package cleverref, which was somehow interfering with my ability to reference equation numbers in the usual non-clever way (this is not the problem OP had, but this post is a top hit on google when I searched for my symptoms so I'm leaving a comment here).

GMB
  • 375
0

For further reference: I solved the same issue by placing the label just next to the \begin{align} command (and with \usepackage{cleveref} active):

\begin{align}\label{eq1}
E=mc^2 \nonumber\\
E=mc^2`
\end{align}

In the text: "... equation~\ref{eq1}"

Laura
  • 1
  • 2
    That works only by chance. The \label should be in the numbered row, not in the unnumbered one. – egreg Aug 03 '20 at 17:59