Skip to content

This error occurs when LaTeX is typesetting a table and detects an alignment character (&) where it did not expect to find one. LaTeX uses alignment characters to separate table columns and will complain if a table tries to use more columns than expected.

Error caused by the tabular environment

The tabular environment is a common source of this error, as demonstrated by the next example. Here, we have written {c|c|c} to specify a table with three (centered) columns, meaning each table row should contain three cells.

\begin{tabular}{c|c|c} % Specify 3 centered columns
   1 & 2 & 3 & 4\\ % ERROR: Uses 4 columns, not 3
   5 & 6 & 7\\
\end{tabular}

 Open this error-generating example in Overleaf

Our example generates the following error message:

Demonstrating the LaTeX table error "Extra alignment tab has been changed to \cr"

and typesets this table:

Explanation of the error

The first & in a table row indicates the start of the second column; consequently, for a three-column table LaTeX expects to see two alignment characters before each line break (\\). However, the first row of our table uses three alignment characters which confuses LaTeX, making it change the unexpected alignment character to the \cr command—an attempt to reduce the number of columns to three. Note that using three alignment characters requires four columns.

How to fix the error

To resolve this error and fix our table, we can either:

  • remove the extra column by deleting the entry
  • add an extra column to the tabular environment options (e.g., writing {c|c|c|c})
  • create a new line (new table row)

Here is an example demonstrating each of these each solutions:

\section*{Removing the extra column entry}

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

\section*{Adding an extra column to the tabular}

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

\section*{Creating a new line (new table row)}

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

 Open this example in Overleaf

This example produces the following output:

Fixing tabular errors

Errors caused by math environments

Mathematical typesetting often requires the alignment of math elements, which is achieved using environments such as array, matrix, and several others. Some math environments can trigger the extra alignment tab error because they use a table to perform their alignment, as demonstrated in the following examples.

The array environment

LaTeX will generate an error if the number of alignment tabs used in an array row exceeds the number of array columns. Here is an example using an array with three columns but the first row tries to use four columns:

\[
\begin{array}{lcl}
g(x) & = & (x+2)^2 & = (x+2)(x+2)\\ % This row triggers the error
& = & x^2+4x+4\\
\end{array}
\]

 Open this error-generating example in Overleaf

This example generates the following error message:

Image showing error in LaTeX array due to too many tab characters

and typesets this array:

\[ \begin{array}{lcl} g(x) & = & (x+2)^2 \\ =(x+2)(x+2) \\ & = & x^2+4x+4\\ \end{array} \]

To correct this error, rewrite the array as follows:

\[
\begin{array}{lcl}
g(x) & = & (x+2)^2 \\
& = & (x+2)(x+2) \\
& = & x^2+4x+4\\
\end{array}
\]

 Open this corrected example in Overleaf

The corrected array produces the following:

\[ \begin{array}{lcl} g(x) & = & (x+2)^2 \\ & = & (x+2)(x+2) \\ & = & x^2+4x+4\\ \end{array} \]

The amsmath matrix environments

The amsmath package provides numerous environments for typesetting matrices, including matrix, pmatrix, bmatrix, Bmatrix, vmatrix, and Vmatrix.

The following pmatrix example tries to use 12 columns but generates an error because amsmath sets a default maximum of 10 columns in typeset matrices.

\documentclass{article}
\usepackage{amsmath} % To access the matrix environment
\begin{document}
\[
\begin{pmatrix}
a_{1,1} & a_{1,2} & a_{1,3} & a_{1,4} & a_{1,5} & a_{1,6} & a_{1,7} & a_{1,8} & a_{1,9} & a_{1,10} & a_{1,11} & a_{1,12} \\
\end{pmatrix}
\]
\end{document}

 Open this error-generating example in Overleaf

To fix the error, change the column-maximum to 12 by writing \setcounter{MaxMatrixCols}{12}, or any value of your choice.

\documentclass{article}
\usepackage{amsmath} % To access the pmatrix environment
\setcounter{MaxMatrixCols}{12}
\begin{document}
\[
\begin{pmatrix}
a_{1,1} & a_{1,2} & a_{1,3} & a_{1,4} & a_{1,5} & a_{1,6} & a_{1,7} & a_{1,8} & a_{1,9} & a_{1,10} & a_{1,11} & a_{1,12} \\
\end{pmatrix}
\]
\end{document}

 Open this corrected example in Overleaf

The corrected example produces the following matrix:

\[ \begin{pmatrix} a_{1,1} & a_{1,2} & a_{1,3} & a_{1,4} & a_{1,5} & a_{1,6} & a_{1,7} & a_{1,8} & a_{1,9} & a_{1,10} & a_{1,11} & a_{1,12} \\ \end{pmatrix} \]

A short note on the \cr command

LaTeX addresses the issue of an unexpected alignment character by substituting it with a fundamental command known as \cr, which is integral to LaTeX's internal mechanics for concluding a table row. Although users utilize the LaTeX \\ macro to indicate the end of a table row, it is actually the \cr command that is executed behind the scenes to terminate the row when the \\ macro is processed.

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