[Tex/LaTex] Why does \begin{align} &&&\cr \end{align} give “Missing number”

alignamsmath

Consider the following MWE:

\documentclass{article}
\usepackage{amsmath,bbm}

\begin{document}

\begin{align}
  &&&\cr
\end{align}

\end{document}

It generates both the "Missing number, treated as zero" and "Illegal unit of measure (pt inserted)" error messages. Why?

(My goal is to have 2 spaced equations on one line but no equation number for that line. I realize I can accomplish this with something like \begin{align} \nonumber a&=1 & b&=2\\ c\end{align} but why is this necessary?)

Best Answer

\cr is not a LaTeX command (it is a TeX primitive) and its use in the middle of an AMS alignment causes a chunk of the alignment code to be omitted as the correct code \\sets up a lot of the internal measurement data before calling \cr internally to finish the row.

If you add \tracingall and compare the logs with \cr and \\ then you will see that the specific cause of the error is that \cr did not terminate the cell as intended and so the \maxcolumn@widths macro was not correctly updated with the column widths.

With \cr it is

\maxcolumn@widths -> \or 0.0pt \or 0.0pt

but with \\ it is

\maxcolumn@widths -> \or 0.0pt \or 0.0pt \or 0.0pt \or 0.0pt \or 0.0pt

align uses an \ifcase to extract the relevant length as it considers each column

but as it is too short, once it gets to column 3 it uses \ifcase3 which means that it tries to read past this \or list and you get:

\maxcolumn@widths -> \or 0.0pt \or 0.0pt
{case 3}
! Missing number, treated as zero.
<to be read again> 
                   \relax 

Don't use TeX primitives in the middle of complicated LaTeX code:-)