> 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/zh-tw/latex-cuo-wu/07-extra-alignment-tab-has-been-changed-to-cr.md).

# 多餘的對齊定位點已改為 \cr

當 LaTeX 在排版表格並偵測到一個對齊字元（`&`）出現在它沒預期會找到的位置時，就會發生這個錯誤。LaTeX 使用對齊字元來分隔表格欄位，並且會 [報錯](#a-short-note-on-the-cr-command) ，如果表格嘗試使用比預期更多的欄位。

## 由 tabular 環境引起的錯誤

tabular 環境是這個錯誤的常見來源，如下一個範例所示。在這裡，我們寫了 `{c|c|c}` 來指定一個具有三個（置中）欄位的表格，這表示每一列應包含三個儲存格。

```latex
\begin{tabular}{c|c|c} % 指定 3 個置中欄位
   1 & 2 & 3 & 4\\ % 錯誤：使用了 4 欄，而不是 3 欄
   5 & 6 & 7\\
\end{tabular}
```

[在此開啟 **會產生錯誤的** 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)

我們的範例會產生以下錯誤訊息：

![示範 LaTeX 表格錯誤「Extra alignment tab has been changed to \cr」](/files/8f837873fcc602018788c9a8c8983e79e8313249)

並排版出這個表格：

![](/files/2165021c650ba8a333c7d448edf43ac3501d0507)

### 錯誤說明

第一個 `&` 在表格列中表示 *第二次* 欄位的開始；因此，對於一個三欄表格，LaTeX 預期會在每一個換行符號（ *兩種* ）之前看到對齊字元`\\`。然而，我們表格的第一列使用了 *三個* 對齊字元，這使 LaTeX 感到困惑，讓它將這個意外的對齊字元改成 [`\cr` 命令](#a-short-note-on-the-cr-command)——試圖將欄位數減少到三欄。請注意，使用 *三個* 對齊字元需要 *四個* 欄。

### 如何修正此錯誤

若要解決此錯誤並修正我們的表格，我們可以：

* 刪除條目
* 在 tabular 環境選項中增加一個欄位（例如寫成 `{c|c|c|c}`)
* 建立新的一行（新的表格列）

以下是一個示範這些解決方案的範例：

```latex
\section*{移除多餘的欄位條目}

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

\section*{在 tabular 中增加一個欄位}

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

\section*{建立新的一行（新的表格列）}

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

[在 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)

此範例會產生以下輸出：

![修正 tabular 錯誤](/files/d14cc02427862b7837cf83d9364301d4dce360c9)

## 由數學環境引起的錯誤

數學排版通常需要對齊數學元素，而這可以透過像 `array`, `矩陣`，以及其他幾種環境來達成。某些數學環境可能會因為它們使用表格來進行對齊，而觸發多餘的對齊分頁錯誤，如以下範例所示。

### array 環境

如果 array 列中使用的對齊分頁數超過 array 欄數，LaTeX 就會產生錯誤。以下是一個使用三欄 array，但第一列試圖使用四欄的範例：

```latex
\[
\begin{array}{lcl}
g(x) & = & (x+2)^2 & = (x+2)(x+2)\\ % 這一列會觸發錯誤
& = & x^2+4x+4\\
\end{array}
\]
```

[在此開啟 **會產生錯誤的** 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)

此範例會產生以下錯誤訊息：

![因為標籤數過多而導致 LaTeX array 錯誤的圖片](/files/533f9ea84409fe6e23da4df619702e62ab4a5301)

並排版出這個 array：

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

要修正此錯誤，請將 array 改寫如下：

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

[在此開啟 **已修正** 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)

修正後的 array 會產生以下內容：

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

### amsmath 的矩陣環境

該 `amsmath` 套件提供許多用於排版矩陣的環境，包括 `矩陣`, `pmatrix`, `bmatrix`, `Bmatrix`, `vmatrix`，以及 `Vmatrix`.

以下 `pmatrix` 範例試圖使用 12 欄，但會產生錯誤，因為 `amsmath` 在排版矩陣時預設將最大欄數設為 10。

```latex
\documentclass{article}
\usepackage{amsmath} % 存取矩陣環境
\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}
```

[在此開啟 **會產生錯誤的** 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)

要修正此錯誤，請將最大欄數改為 12，寫成 `\setcounter{MaxMatrixCols}{12}`，或你選擇的任何數值。

```latex
\documentclass{article}
\usepackage{amsmath} % 存取 pmatrix 環境
\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}
```

[在此開啟 **已修正** 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)

修正後的範例會產生以下矩陣：

$$\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}$$

## 關於 \cr 指令的簡短說明

LaTeX 會透過將意外的對齊字元替換為一個稱為 `\cr`的基本指令來處理這個問題，這個指令對 LaTeX 內部結束表格列的機制至關重要。雖然使用者會使用 LaTeX 的 `\\` 巨集來表示表格列的結束，但實際上執行的是 `\cr` 指令，當 `\\` 巨集被處理時，它會在幕後終止該列。


---

# 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/zh-tw/latex-cuo-wu/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.
