# eqnarray vs align

### Motivation

I want to include a list of related equations, say, for a proof, in my LaTeX document. As far as I know, I have two good options, eqnarray and align.

### Question

What is the difference between eqnarray and align, and how do I know which I should be using? Or does it matter at all?

-

Although eqnarray may seem to work "well enough", Avoid eqnarray! Avoid eqnarray! Avoid eqnarray!

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.

-
"avoid eqnarray" has been updated and published in tugboat 33:1. this will be accessible only to tug members until spring 2013, but after that it will be open to anyone. –  barbara beeton Dec 15 '12 at 17:50
Why do we have eqnarray then? –  masu Oct 29 '13 at 22:43
@masu: eqnarray was written before the other (better) environments were written. Now that the better ones exist, there is no longer any reason to use eqnarray (unless for some reason you can't use the amsmath ones). –  ShreevatsaR Oct 30 '13 at 4:03
@ShreevatsaR and I should have thought about backward compatibility. –  masu Oct 30 '13 at 8:38
The TUGboat article mentioned by Barbara: tug.org/TUGboat/tb33-1/tb103madsen.pdf. –  Speravir Mar 5 '14 at 1:37

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 just array with a default preamble); align has one. x + y &=& z versus x + 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 \\* in eqnarray, but won't work in align (since * shows up commonly in equations)

(largely from The LaTeX Companion §8.2.1)

-
i consider the first point to be an advantage of eqnarray. how can i simulate this behavior with align? i need it whenever i have operators of different width, e.g. = vs ==. i want = to be centered below ==, not left aligned to it. –  peter Jul 24 '13 at 12:19
align allows page breaks between lines with the global declaration \allowdisplaybreaks. –  skpblack Oct 3 '14 at 0:11

The align environment only works if you use the AMS (American Mathematical Society) packages. If you need to use journal specific document classes or style files, the align environment may not be available. (For example, when I needed to use the iopart class for submission to an Institute of Physics journal, I had to change all my aligns to eqnarrays for the file to compile.

But unless you are forced to, I generally recommend the align environment. Here's a good write-up of what the differences are.

-

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}


-

If you must use the eqnarray environment, there's a package called eqnarray (available here) that at least removes the excessive space around the middle column. Compare:

\documentclass{article}

\usepackage{eqnarray,amsmath}

\begin{document}

\begin{eqnarray*}
A&=&B,\\
C&=&D,\\
E&=&F
\end{eqnarray*}

\begin{align*}
A&=B,\\
C&=D,\\
E&=F
\end{align*}

\end{document}


The package is for LaTeX 2.09, but it might still work.

I notice that, in my example, the eqnarray* and align* are centered very slightly differently (the eqnarray* is less than 1 point to the left of the align*). I'm not sure why. If you use {B,} and {D,} instead of B, and D, in the eqnarray*, the two displays come out centered exactly the same, so I assume that the ending punctuation symbols are causing the problem. (The default eqnarray* appears to have the same issue.)

-

## protected by WernerJan 20 '12 at 7:42

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?