> 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/22-misplaced-noalign.md).

# \noalign 放置位置錯誤

當你使用了 **`\hline`** 不正確地。

## 常見原因

**在表格外使用 \hline：**

該 **`\hline`** 命令只能在一個 **`tabular`** 環境中。你不能用它在文件其他地方加入水平線，例如標題頁或頁首。這個錯誤的範例如下：

```latex
%在你的前言中
\title{關於熱的一般分子理論}
\author{A. Einstein}

% 在你的文件正文中
\maketitle

\hline
```

這將產生下面顯示的錯誤

main.tex，第 5 行

位置錯誤的 \noalign。

\hline ->\noalign {\ifnum 0=\`}\fi \hrule \\@height \arrayrulewidth \futurelet... l.10 \hline 我預期只會在對齊的 \cr 之後看到 \noalign。繼續吧，我會忽略這種情況。

當你想在 tabular 環境外加入水平線時，你必須使用 **`\hrule`**.

**在表格中錯誤使用 \hline：**

當使用 **`\hline`** 在表格中，除了第一個之外的每一個實例前都必須加上 **`\\`**。下面顯示了此錯誤的範例

```latex
\begin{tabular}{|l|l|} \hline
    名字：& Albert \\ \hline
    第二個名字：& Einstein \hline
\end{tabular}
```

第一個 **`\hline`** 這裡的命令是沒問題的，因為第一個 **`\hline`** 在表格中不需要在前面加上 **`\\`**。問題在於我們最後一個 **`\hline`** 這一個確實需要在前面加上 **`\\`**。正確的寫法如下：

```latex
\begin{tabular}{|l|l|} \hline
    名字：& Albert \\ \hline
    第二個名字：& Einstein \\ \hline
\end{tabular}
```

![Table.PNG](/files/a9e47cd79d148fa68dd4bd2d8d6ef356d1f8c04f)


---

# 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/22-misplaced-noalign.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.
