[Tex/LaTex] Difference between align and alignat environments

amsmath

What is the difference between align and alignat environments?

Best Answer

The first difference we find is in the syntax for calling the two environments:

\begin{align}

doesn't want an additional argument, while

\begin{alignat}{<number>}

requires it. Both environments create alignments based on pairs of rl columns; align will create as many as desired based on the environment's contents, while alignat requires you to specify how many pairs you want in advance.

However, the two environments differ much more than described above. The align environment will add horizontal space between the column pairs

<r col><l col> <space> <r col><l col> <space> <...>

while alignat will insert no horizontal space. For an instance, see Align-environment: Align on the left side, where an alignment of type

<l col><l col>

is desired, which is obtained by using empty right aligned columns:

\begin{alignat}{2}
&ABC  &&= ABC - AB\\
&ABCD &&= ABC - ABCDEFG
\end{alignat}

Both environments have an implicit {} at the beginning of cells in the left aligned columns, to help getting good spacing when a cell starts with a relation or operation symbol.

Other uses of alignat are when we want finer control on the horizontal spacing between (pairs of) columns. Such spacing should be specified explicitly such as in

\begin{alignat*}{3}
& m   \quad && \text{módulo}            \quad && m>0\\
& a   \quad && \text{multiplicador}     \quad && 0<a<m\\
& c   \quad && \text{constante aditiva} \quad && 0\leq c<m\\
& x_0 \quad && \text{valor inicial}     \quad && 0\leq x_0 <m
\end{alignat*}

(see Aligning equations with text with alignat). Such a control is not possible with align, because it adds the same horizontal space between all column pairs.

Both environments have the * form and accept \tag or \notag in any row.

There are also the “inner” versions aligned and alignedat, that obey the same rules, for use inside math mode (inline formulas, displayed formulas, math alignments).