[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 ofrlcolumns; 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
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
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).
The star at the end of the name of a displayed math environment causes that the formula lines won't be numbered. Otherwise they would automatically get a number.
You can read about that in the amsmath user's guide since align belongs to amsmath.
Such information can usually be found in the package documentation. Type texdoc packagename at the command prompt or visit http://ctan.org/pkg/packagename. If you use google or another search engine, look for starred and commandname.
Commonly, a star symbol * means a version of a command that behaves differently from the original. That often means suppressing numbering but could also refer to special features. For example, have a look at What's the difference between \newcommand and \newcommand*?
Although I agree with egreg's comment, the difference is mainly of an aesthetic nature imo.
It depends on the context which version to use, which is also how amsmath decides which to use.
Some examples:
a_1,\ldots,a_n aligns better than a_1,\cdots,a_n.
But a_1 \to \ldots \to a_n aligns worse than a_1 \to \cdots \to a_n.
The alignment chosen by amsmath is usually the one commonly found in mathematical articles. However, I guess its not really wrong or anything to deviate from it.
Best Answer
The first difference we find is in the syntax for calling the two environments:
doesn't want an additional argument, while
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, whilealignat
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 pairswhile
alignat
will insert no horizontal space. For an instance, see Align-environment: Align on the left side, where an alignment of typeis desired, which is obtained by using empty right aligned columns:
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(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
andalignedat
, that obey the same rules, for use inside math mode (inline formulas, displayed formulas, math alignments).