> 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/01-abovedisplayskip-and-related-commands.md).

# \abovedisplayskip 及相关命令

`\abovedisplayskip` 是用于控制 TEX 引擎在显示公式前后添加多少胶水（可伸缩空白）的 4 条命令之一：

* `\abovedisplayskip[=]` *胶水*
* `\belowdisplayskip[=]` *胶水*
* `\abovedisplayshortskip[=]` *胶水*
* `\belowdisplayshortskip[=]` *胶水*

其中 *胶水* 表示某种“可伸缩空白”，而“\[=]”表示后面可以跟一个 *可选的* “=”号。

**用法示例** `\abovedisplayskip=12pt plus 3pt minus 9pt` （“=”符号是可选的）。

上面的 4 条命令都可用于设置（存储）你偏好的胶水值，供 TEX 在排版显示数学公式时使用。

#### 选择使用哪些胶水

与大多数 TEX 算法一样，完整说明需要考虑 *许多* 细节，但是， *粗略地说*，TEX 会检查段落的最后一行与公式是否“重叠”：该比较的结果决定在公式上方和下方放置哪种胶水。实际上，TEX 还会检测是否存在公式编号。

如果公式前面是一行“足够短”的文字，则存储在 `\abovedisplayshortskip` 中的胶水将插入到公式上方，而存储在 `\belowdisplayshortskip` 中的胶水值将插入到公式下方。对于较长的行（或较长的公式），TEX 会改为在 `\abovedisplayskip` 公式上方插入胶水，而在 `\belowdisplayskip` 其下方插入胶水。

关于 TEX 究竟如何选择在显示公式（`\abovedisplayskip` 或 `\abovedisplayshortskip`）或在其下方（`\belowdisplayskip` 或 `\belowdisplayshortskip`）放置哪种胶水的详细解释可见于《The TEXbook》第 188–9 页。

#### 示例

为演示起见，我们将为各种胶水使用一些“极端”值，以便其效果清晰可见。我们将选择 `\abovedisplayshortskip=-20pt` 这将使一个显示公式 *向上* 移动 20pt，前提是该公式前面是一行足够短的文字。我们还将使用 `\belowdisplayshortskip=100pt` 来设置插入到显示公式下方的胶水（100 pt）。这里，我们将使用薛定谔方程作为示例来说明这些命令的效果：

```
\[ \frac{\hbar^2}{2m}\nabla^2\Psi + V(\mathbf{r})\Psi
= -i\hbar \frac{\partial\Psi}{\partial t} \]
```

从而得到如下数学式：

$$\frac{\hbar ^2}{2m}\nabla ^2\Psi + V(\mathbf{r})\Psi = -i\hbar \frac{\partial \Psi }{\partial t}$$ 下面的示例使用上面提到的“极端”胶水值：

```
\abovedisplayshortskip=-20pt
\belowdisplayshortskip=100pt
\noindent A short last line...
\[ \frac{\hbar^2}{2m}\nabla^2\Psi + V(\mathbf{r})\Psi
= -i\hbar \frac{\partial\Psi}{\partial t} \]
... 一行简短的结尾文字。
```

下图显示了结果：

![](/files/d87c8a61a75fd3b67a8fa5304efc5ab08c43f8e4)

如你所见，薛定谔方程已向上移动 20pt，并在其下方增加了 100pt 的间距。

不过，如果我们现在改用一个更宽的公式，并且 `\abovedisplayshortskip=-20pt` 和 `\belowdisplayshortskip=100pt` 或者增加段落最后一行的长度，那么这两个胶水设置就会被忽略，因为显示公式与最后一行“重叠”了。这里，TEX 现在使用胶水 `\abovedisplayskip` 公式上方插入胶水，而在 `\belowdisplayskip` 放在其下方。这里，我们没有为 `\abovedisplayskip` 或 `\belowdisplayskip` 设置数值，而只是使用它们的默认值：

```
\abovedisplayshortskip=-20pt
\belowdisplayshortskip=100pt
\noindent A short last line...
\[\int_{x^2 + y^2 \leq R^2} f(x,y)\,dx\,dy
= \int_{\theta=0}^{2\pi} \int_{r=0}^R
f(r\cos\theta,r\sin\theta) r\,dr\,d\theta.\]
... 一行简短的结尾文字。
```

下图显示了结果：

![](/files/9c5d6e414e41faab214f01780317f789ca7f1659)

现在我们来排版薛定谔方程，但要确保最后一行更长：

```
\abovedisplayshortskip=-20pt
\belowdisplayshortskip=100pt
\noindent 现在在我们的 Schr\&#x0022;{o}dinger 方程前面有一行更长的文字。因此，
\TeX{} 将在公式上方使用 \verb|\abovedisplayskip| 胶水，并在
其下方使用 \verb|\belowdisplayskip|，忽略我们提供的“极端”值：
\verb|\abovedisplayshortskip=-20pt| 和 \verb|\belowdisplayshortskip=100pt|。
\[ \frac{\hbar^2}{2m}\nabla^2\Psi + V(\mathbf{r})\Psi
= -i\hbar \frac{\partial\Psi}{\partial t} \]
... 一行简短的结尾文字。
```

下图显示了结果：

![](/files/2dca7e68f5cda990eb9b22b175ff125e6dca8662)

#### 相关命令

* `\displaywidth`\[=] *长度*
* `\displayindent`\[=] *长度*
* `\predisplaysize`\[=] *长度*

其中 *长度* 是在 TEX 可识别单位中的一个长度。“\[=]”表示后面可以跟一个 *可选的* 等号。


---

# 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/01-abovedisplayskip-and-related-commands.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.
