> 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/tex-latex-ji-yuan/07-overfullrule.md).

# \overfullrule

`\overfullrule[=]` *长度*

其中：

* “`[=]`”表示等号是可选的。
* *长度* 是以 TEX 能理解的单位指定的一个量——例如 pt、bp、mm 等。

当 TEX 检测到某个 hbox 溢出时——例如排版段落中的一行，或者某个文本位于一个 `\hbox{..}`——它会将该信息写入日志文件。此外，TEX 引擎还提供 `\overfullrule` 该命令可用于指示 TEX 在出问题的盒子末尾添加一条短规则线，作为对用户的视觉警告。

**使用示例**

由于“=”符号是可选的，你可以写 `\overfullrule=10pt` 或 `\overfullrule 10pt`.

注意 LATEX 将 `\overfullrule` 设为 0pt，而 Plain TEX 将其设为 5pt。

#### 一个例子

我们将使用一个 `\hbox{}` 它将会溢出： `\hbox to 10pt{This box will be overfull}` 并将 `\overfullrule` 设为一个非零值，比如 10mm：

```
\overfullrule=10mm\hbox to 10pt{This box will be overfull}\par
```

下图显示了输出结果：

![](/files/b7175877f4465e8f5b94dd9b19d2692b4ba46daa)

如你所见，一条长度为 10mm 的规则线已被添加到这个溢出的 `\hbox`。现在将 `\overfullrule=0mm` 设为，以防显示溢出盒子的规则线：

```
\overfullrule=0mm\hbox to 10pt{This box will be overfull}
```

下图显示了输出结果：

![](/files/73cb6a79077c436a369606dba9afc1c14f87e26e)

结果中的 `\hbox` 仍然是溢出的，但这次显示时没有溢出规则线来强调这一事实。

#### 另一个示例：段落中的行

当 TEX 将一个段落断行成排版文本时，段落中的每一行都会存储在一个 `\hbox`。通过设置 `\overfullrule` 为一个非零值，TEX 就可以显示溢出的行。下面的示例展示了在段落中溢出的行末尾显示溢出规则线。

要创建一个段落，我们将把一些文本放在一个窄的 `\vbox`，设置 `\overfullrule=10pt`，并给这个盒子画上边框。注意，由于我们使用了 `\verb` 命令，我们首先需要将 `\vbox` 保存到一个盒子寄存器（100）中，然后使用 LATEX 命令（宏） `\fbox` 在其周围画一个紧边框，这样更容易看出溢出的行。

```
\overfullrule=10pt
\setlength{\fboxsep}{0pt}% To ensure a tight border with no gap
\setbox100=\vbox{\hsize=30mm 在这个 vbox 中，我们将设置
行宽为 30mm，使用 \verb|\hsize=30mm|。
我们正在一个 \verb|\vbox| 中排版一些文本
因为这会使 \TeX{} 执行断行
并将段落构建为一叠水平盒子。
对于某些行，\TeX{} 可能无法找到合适的
断行方式，从而导致行过宽，无法适配
在 30mm 的宽度内。由于 \verb|\overfullrule|
不是零（10pt），那些溢出的行会
由宽度为 10pt 的溢出规则线标示。注意，对 \TeX{} 来说，
这个盒子仍然被认为宽度为 30mm，尽管
有些行放不下，而且会添加一个 \verb|\overfullrule|
宽度为 10pt 的规则线到某些行的末尾。}
\fbox{\copy100}
```

下图显示了输出结果：

![](/files/3c08f4842de271af7aaa3304914a35c447bf35bc)


---

# 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/tex-latex-ji-yuan/07-overfullrule.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.
