> 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-cn/latex-cuo-wu/22-misplaced-noalign.md).

# \noalign 放置位置不当

当你使用了 **`\hline`** 不正确地。

## 常见原因

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

该 **`\hline`** 该命令只能在一个 **`tabular`** 环境中使用。你不能用它在文档的其他位置插入水平线，例如标题页或页眉。这个错误的一个示例如下：

```latex
%在导言区
\title{论热的普遍分子理论}
\author{A. 爱因斯坦}

% 在文档正文中
\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
    第二个姓名：& 爱因斯坦 \hline
\end{tabular}
```

第一个 **`\hline`** 此处的命令没有问题，因为第一处 **`\hline`** 在表格中不需要在其前面加上 **`\\`**。问题在于我们的最后一个 **`\hline`** 它之前确实需要加上 **`\\`**。这个表格的正确写法是：

```latex
\begin{tabular}{|l|l|} \hline
    名字：& Albert \\ \hline
    第二个姓名：& 爱因斯坦 \\ \hline
\end{tabular}
```

![Table.PNG](/files/604163afdf037bf25c73df722dc9333f0c581c8c)


---

# 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-cn/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.
