LaTeX error "Extra alignment tab has been changed to \cr": cause and fix
A table row has more & than the column specification allows. TeX treats the surplus & as the end of the row.
Why it happens
- The row has one cell too many, for example three cells in a table declared as
{ll}. - The
\\at the end of the previous row is missing, so two rows count as one. - An
&that belongs to the text, as inR&D, is not escaped. - A matrix from
amsmathhas more than 10 columns.
How to fix it
- Count the
&in the row the log names. A table with n columns takes n − 1 of them per row. - Add the missing column to the specification, for example
{lll}instead of{ll}. - End every row with
\\, and write an ampersand that should be printed as\&. - For a wide matrix, raise the limit in the preamble:
\setcounter{MaxMatrixCols}{12}.
A document that produces the message
\documentclass{article}
\begin{document}
\begin{tabular}{ll}
Name & Value & Unit \\
Length & 3 & m \\
\end{tabular}
\end{document}The corrected document
\documentclass{article}
\begin{document}
\begin{tabular}{lll}
Name & Value & Unit \\
Length & 3 & m \\
\end{tabular}
\end{document}Both documents were compiled with pdfLaTeX from TeX Live 2023. The first produces the message, the second compiles without an error.
Finding the line in the editor
The editor lists every error and warning of a compile run with file and line. Select an entry and the cursor jumps to that line. See Error list with jump to the line.
Related pages
- Error Misplaced alignment tab character &
- Error Misplaced \noalign
- How-to Create a table in LaTeX
- How-to Matrices in LaTeX