eqnarray vs align
Although eqnarray
may seem to work "well enough", Avoid eqnarray! Avoid eqnarray! Avoid eqnarray!
Two main problems are mentioned in the doc above:
eqnarray
sets horizontal space around the=
operator that is not consistent with the space set in other environments, such as\[...\]
or$$...$$
(it is wider).eqnarray
(alsoeqnarray*
!) has an ill-defined equation numbering, which leads to numbering errors on referencing—mostly when using the command\nonumber
Use align
and the rest of the ams environments. See texdoc amsldoc
(PDF) or the short math guide for LaTeX for documentation on how to use them.
align
is from amsmath
, while eqnarray
is from base LaTeX, so I would expect the former to be better. Some differences:
eqnarray
has two alignment points (it's basically justarray
with a default preamble);align
has one.x + y &=& z
versusx + y &= z
eqnarray
changes the spacing at the alignment points depending on different factors;align
keeps it fixed (which is generally what you want)eqnarray
allows page breaks between lines;align
doesn't\\ *
is treated the same as\\*
ineqnarray
, but won't work inalign
(since*
shows up commonly in equations)
(largely from The LaTeX Companion §8.2.1)
Besides the better spacing and the less ampersands to type, a big advantage of align
vs eqnarray
is that you can include a \qedhere
at the end of the last line and have the nice CQFD square (also called a “Halmos”) placed at the same height as your last formula, and not underneath.
\begin{proof} The proof is a follows:
\begin{align}
(x+y)^3&=(x+y)(x+y)^2\\
&=(x+y)(x^2+2xy+y^2)\\
&=x^3+3x^2y+3xy^3+x^3.\qedhere
\end{align}
\end{proof}