# Double backslash on last line of matrix

Is \\ necessary on the final line of environments like matrix, align, and gather? For example, with amsmath,

$\begin{bmatrix} 3 & 1\\ 2 & 4\\ \end{bmatrix}$


and

$\begin{bmatrix} 3 & 1\\ 2 & 4 \end{bmatrix}$


seem to produce the same output. But are they really the same? Is one preferable to the other, or is it a matter of taste? From my understanding, \\ in one of these environments is used to separate lines, and there's nothing else to separate the final line from, so it's not necessary.

• If it produces the same output, I guess there's no difference. Nov 12 '18 at 14:11
• I think there's no rule for this. I think it depends on the implementation of the environment. With align, for instance, you get an undesired line if you add the \\ at the end. Nov 12 '18 at 14:16

There is no difference at all for bmatrix. There is for align.

Any array or tabular allows a trailing \\; it is obviously mandatory if \hline is needed at the bottom, but otherwise omitting it is safe.

Since Xmatrix (where X stands for noting, p, b, B, v or V) is array in disguise, the same applies. Also cases falls in this class.

It's very different with align, alignat, xalignat, flalign and gather (or *-forms thereof), where a trailing \\ would produce a new empty row (with the equation number in the case of no *), so it must be avoided.

As a habit, I tend to avoid the trailing \\ in Xmatrix, just for symmetry with the alignment environments mentioned above.