> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/latex-errors/07-extra-alignment-tab-has-been-changed-to-cr.md).

# Extra alignment tab has been changed to \cr

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](#a-short-note-on-the-cr-command) 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.

```latex
\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](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Example+of+a+tabular+with+too+many+alignment+characters\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Btabular%7D%7Bc%7Cc%7Cc%7D+%25+Specify+3+centered+columns%0A+++1+%26+2+%26+3+%26+4%5C%5C+%25+ERROR%3A+Uses+4+columns%2C+not+3%0A+++5+%26+6+%26+7%5C%5C%0A%5Cend%7Btabular%7D%0A%5Cend%7Bdocument%7D)

Our example generates the following error message:

![Demonstrating the LaTeX table error "Extra alignment tab has been changed to \cr"](/files/926ULac8Ti0q1AmJH20u)

and typesets this table:

![](/files/KqMaRNcDIZjaBHAyOLIh)

### 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](#a-short-note-on-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:

```latex
\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](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Options+for+correcting+a+tablular+error\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5Csection%2A%7BRemoving+the+extra+column+entry%7D%0A%0A%5Cbegin%7Bcenter%7D%0A%5Cbegin%7Btabular%7D%7Bc%7Cc%7Cc%7D%0A+++1+%26+2+%26+3%5C%5C%0A+++5+%26+6+%26+7%5C%5C%0A%5Cend%7Btabular%7D%0A%5Cend%7Bcenter%7D%0A%0A%5Csection%2A%7BAdding+an+extra+column+to+the+tabular%7D%0A%0A%5Cbegin%7Bcenter%7D%0A%5Cbegin%7Btabular%7D%7Bc%7Cc%7Cc%7Cc%7D%0A+++1+%26+2+%26+3+%26+4%5C%5C%0A+++5+%26+6+%26+7%5C%5C%0A%5Cend%7Btabular%7D%0A%5Cend%7Bcenter%7D%0A%0A%5Csection%2A%7BCreating+a+new+line+%28new+table+row%29%7D%0A%0A%5Cbegin%7Bcenter%7D%0A%5Cbegin%7Btabular%7D%7Bc%7Cc%7Cc%7D%0A+++1+%26+2+%26+3+%5C%5C%0A+++4+%26+++%26+++%5C%5C%0A+++5+%26+6+%26+7+%5C%5C%0A%5Cend%7Btabular%7D%0A%5Cend%7Bcenter%7D%0A%5Cend%7Bdocument%7D)

This example produces the following output:

![Fixing tabular errors](/files/yar33tmBTgWIiTRWj0oO)

## 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:

```latex
\[
\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](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=An+array+with+too+many+alignment+characters\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5B%0A%5Cbegin%7Barray%7D%7Blcl%7D%0Ag%28x%29+%26+%3D+%26+%28x%2B2%29%5E2+%26+%3D+%28x%2B2%29%28x%2B2%29%5C%5C+%25+This+row+triggers+the+error%0A%26+%3D+%26+x%5E2%2B4x%2B4%5C%5C%0A%5Cend%7Barray%7D%0A%5C%5D%0A%5Cend%7Bdocument%7D)

This example generates the following error message:

![Image showing error in LaTeX array due to too many tab characters](/files/VctC1cRbbF0yLY4KAxOa)

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:

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

[Open this **corrected** example in Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Corrected+version+of+the+array+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5B%0A%5Cbegin%7Barray%7D%7Blcl%7D%0Ag%28x%29+%26+%3D+%26+%28x%2B2%29%5E2+%5C%5C%0A%26+%3D+%26+%28x%2B2%29%28x%2B2%29+%5C%5C%0A%26+%3D+%26+x%5E2%2B4x%2B4%5C%5C%0A%5Cend%7Barray%7D%0A%5C%5D%0A%5Cend%7Bdocument%7D)

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.

```latex
\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](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=A+pmatrix+with+too+many+columns\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D+%25+To+access+the+matrix+environment%0A%5Cbegin%7Bdocument%7D%0A%5C%5B%0A%5Cbegin%7Bpmatrix%7D%0Aa_%7B1%2C1%7D+%26+a_%7B1%2C2%7D+%26+a_%7B1%2C3%7D+%26+a_%7B1%2C4%7D+%26+a_%7B1%2C5%7D+%26+a_%7B1%2C6%7D+%26+a_%7B1%2C7%7D+%26+a_%7B1%2C8%7D+%26+a_%7B1%2C9%7D+%26+a_%7B1%2C10%7D+%26+a_%7B1%2C11%7D+%26+a_%7B1%2C12%7D+%5C%5C%0A%5Cend%7Bpmatrix%7D%0A%5C%5D%0A%5Cend%7Bdocument%7D)

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

```latex
\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](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=A+pmatrix+with+12+columns\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D+%25+To+access+the+pmatrix+environment%0A%5Csetcounter%7BMaxMatrixCols%7D%7B12%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5B%0A%5Cbegin%7Bpmatrix%7D%0Aa_%7B1%2C1%7D+%26+a_%7B1%2C2%7D+%26+a_%7B1%2C3%7D+%26+a_%7B1%2C4%7D+%26+a_%7B1%2C5%7D+%26+a_%7B1%2C6%7D+%26+a_%7B1%2C7%7D+%26+a_%7B1%2C8%7D+%26+a_%7B1%2C9%7D+%26+a_%7B1%2C10%7D+%26+a_%7B1%2C11%7D+%26+a_%7B1%2C12%7D+%5C%5C%0A%5Cend%7Bpmatrix%7D%0A%5C%5D%0A%5Cend%7Bdocument%7D)

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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/latex-errors/07-extra-alignment-tab-has-been-changed-to-cr.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
