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.

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}

\begin{equation}
  t=\frac{d}{v}\\\nonumber
  \label{eq:3}
\end{equation}

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

share|improve this question
2  
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 at 17:07

1 Answer 1

up vote 3 down vote accepted

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]
\begin{equation}
t=\frac{d}{v}  \label{eq:3}
\end{equation}
\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}

enter image description here

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.

share|improve this answer

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.