Aller au contenu

This error occurs when LaTeX detects more alignment tabs than it was expecting, and changes one of them to \cr, which is a primitive TeX way of creating line breaks.

Common Causes

Incorrect number of columns in table:

When using environments such use alignment characters (&), such as table, align or matrix, we need to make sure that the number of columns specified in the environment matches the number of alignment characters (&) we use before a line break. An example of a mistake is shown below. Here we have written {c|c|c} to specify that we would like three centred columns before each line break, however in the first line of our table, we have included 3 alignment characters and hence four columns. This causes LaTeX to get confused and change one of the alignment characters to \cr.

\begin{tabular}{c|c|c}
   1 & 2 & 3 & 4 \\
   5 & 6 & 7
\end{tabular}

Tablealign.PNG

This then generates an error message which looks like

main.tex, line 7

Extra alignment tab has been changed to \cr.

<recently read> \endtemplate l.7 1 & 2 & 3 & 4 \\ You have given more \span or & marks than there were in the preamble to the \halign or \valign now in progress. So I'll assume that you meant to type \cr instead. [1

To resolve this error and fix our table, we can either get rid of the extra column by deleting the entry, specify an extra column in the environment options, or place the extra entry on a new line ourselves. An example of each is shown below:

Removing the extra column entry looks like

\begin{tabular}{c|c|c}
   1 & 2 & 3 \\
   5 & 6 & 7
\end{tabular}

Tablealignfix1.PNG

Adding an extra column in the environment options looks like

\begin{tabular}{c|c|c|c}
   1 & 2 & 3 & 4 \\
   5 & 6 & 7
\end{tabular}

Tablealignfix2.PNG

Creating a new line (new row) looks like

\begin{tabular}{c|c|c}
   1 & 2 & 3 \\
   4 &   &   \\
   5 & 6 & 7
\end{tabular}
\end{center}

Tablealignfix3.PNG

Overleaf guides

LaTeX Basics

Mathematics

Figures and tables

References and Citations

Languages

Document structure

Formatting

Fonts

Presentations

Commands

Field specific

Class files

Advanced TeX/LaTeX