When using the alignat
environment I encounter a strange equation numbering problem. It's rather hard to describe, but here is an MWE. I describe the output below.
\documentclass[]{memoir}
\usepackage{amsmath}
\listfiles
\begin{document}
\frontmatter
\mainmatter
\begin{alignat}{2}
1 & = 2 \\ \nonumber
1 & = 2
\label{eqn1}
\end{alignat}
This calls equation~\eqref{eqn1}.
\begin{alignat}{2}
2 & = 3 \\ \nonumber
2 & = 3
\label{eqn2}
\end{alignat}
This calls equation~\eqref{eqn2}.
\begin{equation}
3 = 4
\label{eqn3}
\end{equation}
This calls equation~\eqref{eqn3}.
\end{document}
The output from that correctly numbers the equations. However, the first sentence reads "This calls equation (2)." The second reads "This calls equation (??)." The third correctly reads "This calls equation (3)."
The log notes the following when compiling:
LaTeX Warning: Reference `eqn2' on page 1 undefined on input line 25.
I checked the list of style file versions that are being accessed and they're all from the latest TeX distribution (which I updated a few weeks ago). In other words everything's coming from the main tex distribution tree: /usr/local/texlive/2012/texmf-dist/tex/latex/...
Even so, here's the file list from the log file:
*File List*
memoir.cls 2011/03/06 v3.6j configurable book, report, article document cl
ass
ifpdf.sty 2011/01/30 v2.3 Provides the ifpdf switch (HO)
ifetex.sty 2011/12/15 v1.2 ifetex
ifxetex.sty 2010/09/12 v0.6 Provides ifxetex conditional
ifluatex.sty 2010/03/01 v1.3 Provides the ifluatex switch (HO)
etex.sty 1998/03/26 v2.0 eTeX basic definition package (PEB)
mem10.clo 2008/01/30 v0.3 memoir class 10pt size option
mempatch.sty 2009/07/24 v6.0f Patches for memoir class v1.6180339
amsmath.sty 2000/07/18 v2.13 AMS math features
amstext.sty 2000/06/29 v2.01
amsgen.sty 1999/11/30 v2.0
amsbsy.sty 1999/11/29 v1.2d
amsopn.sty 1999/12/14 v2.01 operator names
***********
I'm running on Mac OS X 10.6.8 via TexShop. Any assistance would be greatly appreciated. (Note: I do not have the reputation points to create a new tag for alignat
but it might be useful to have.)
Best Answer
You have to label the line where there's not
\nonumber
. As you're doing, you're labeling an equation without any number.In these environments each line (where
\nonumber
or\notag
is missing) receives a number and can be labeled. I say "line" because in your case you have probably two equations per line (of output); the input is independent of it: the\label
command should go before the\\
command.