aligned environment of amsmath vs array environment
aligned
basically gives you a sequence of r@{}l
column pairs; thus there is no spacing between the two columns in a pair. However, a trick adjusts things so that x&=y
gives the right spacing around the equals sign, or any other relation symbol, which is where usually alignment points are desired.
Some control is made so that lines aren't vertically too near, which isn't done in array
. Here's a visual comparison. Note what must be done differently in array
: one has to add {}
before the =
and use \dfrac
.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
\!\begin{aligned}
a&=bbb & c&=\frac{x}{y} \\
aa&=bbbb & cc&=\frac{x}{y}
\end{aligned}
\]
\[
\begin{array}{@{}r@{}l@{\quad}@{}r@{}l@{}}
a&{}=bbb & c&{}=\dfrac{x}{y} \\
aa&{}=bbbb & cc&{}=\dfrac{x}{y}
\end{array}
\]
\end{document}
(The \!
is due to a glitch in amsmath
that is kept for historical reasons; however it doesn't hurt much if no comparison has to be made. Newer versions of amsmath
don't need it.)
In conclusion, array
and aligned
are different tools, each one has its pros and cons, depending on the problem that has to be solved: array
is more flexible in terms of horizontal alignment of cells, aligned
has other features that make it preferable in some situations. Don't forget alignedat
, that allows to specify the horizontal space between column pairs.
Also to be noticed is that align
and alignat
have no array
counterpart: with array
one can't number lines (easily, at least).
Note that in your example you have not used an alignment point &
The =
are aligned just because B
and E
happen to have the same width. If you changed your example, for example used W
or a different expression altogether then you would have to work a bit harder to get the correct spacing around =
.
Well, for one, notice the difference in spacing and the squeezing of the two lines. I am not aware of the internal mechanism that distinguishes the two, but in terms of usage, aligned is far simpler and easier, allows me to focus on the equation rather than array elements. A similar difference can be noticed in the matrix environments bmatrix, pmatrix, and vmatrix in amsmath vs creation of such matrices manually using various brackets and the array environment.