# \ref counter for equation off by one for labels in align environment

I'm having an issue where the \ref command typesets a number 1 higher than it should be for equations in align; equations are numbered correctly but the references are off.A \ref call to the last equation in align just prints ??. The equation environment works correctly.

\documentclass{pnastwo}
\usepackage[xdvi]{graphicx}
\usepackage{amsmath}
\usepackage{xfrac}
\usepackage{refcount}

\begin{document}
\begin{article}

\begin{align}
vt=d\\\nonumber
\label{eq:1}
\end{align}

\begin{align}
\frac{d}{t}=v\\\nonumber
\label{eq:2}
\end{align}

$$t=\frac{d}{v}\\\nonumber \label{eq:3}$$

Here is the first reference: \ref{eq:1}

And here is the second: \ref{eq:2}

And here is the third: \ref{eq:3}

\end{article}
\end{document}


produces

Here is the first reference: 2

And here is the second: ??

And here is the third: 3

-
The problem is in the combinaton \\ \nonumber \label{eq:1} Why are you doing this (changing line, physically suppressing numbering of that empty line and placing the \label in that line)? –  Gonzalo Medina May 7 '14 at 17:07

You should never have a trailing \\ in environments like align or gather. You shouldn't use align or gather for one line displays, either. Moreover \\ does nothing inside equation.

The \label command refers to the display line where it falls; giving it after \nonumber just confuses LaTeX.

\documentclass{pnastwo}
\usepackage{amsmath}

\usepackage{lipsum} % just for the example

\begin{document}
\begin{article}
\lipsum*[1]
\begin{align}
vt          &= d \label{eq:1} \\
\frac{d}{t} & =v \label{eq:2}
\end{align}
\lipsum*[3]
$$t=\frac{d}{v} \label{eq:3}$$
\lipsum[4]

Here is the first reference: \ref{eq:1}

And here is the second: \ref{eq:2}

And here is the third: \ref{eq:3}

\end{article}
\end{document}


Final notes
The lipsum package is just for providing text. Don't use the xdvi option for graphicx: it exists, but only for backwards compatibility. If you don't use a driver such as dvipdfmx, no option should be given. I also removed the packages not necessary for the example.

-