> 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/ge-shi-hua/05-line-breaks-and-blank-spaces.md).

# 换行与空白

在 LaTeX 中打断文档流并不推荐，除非你正在 [创建宏](/latex/zh-cn/lei-wen-jian/03-writing-your-own-package.md)。不过，有时确实需要对文档布局有更多控制；因此，本文将说明如何插入换行、分页和任意空白。

## 引言

最标准的换行方式是创建一个新段落。这是通过在代码中留出一个空行来实现的。

```latex
\documentclass{article}
\begin{document}
这个段落没有任何信息
其目的是提供一个如何开始新段落的示例。
如你所见，
单行
代码中的换行
在文本中充当空格。

不过，留空一行会开始一个新段落。
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=New+paragraph\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0AThis+paragraph+contains+no+information%0Aand+its+purpose+is+to+provide+an+example+on+how+to+start+a+new+paragraph.%0AAs+you+can+see%2C%0Asingle+line%0Abreak+in+the+code%0Aacts+as+a+space+in+text.%0A%0AHowever%2C+leaving+an+empty+line+starts+a+new+paragraph.%0A%5Cend%7Bdocument%7D)

![LineBreaksEx1aupdated.png](/files/78e8808fcf62b26a9a45ad062c7c27a860aaa323)

这并不是插入换行的唯一命令，在 [下一节](#line-breaks) 中还将介绍另外两个。

## 换行

如前所述，插入换行不止一种方式。

```latex
\documentclass{article}
\usepackage[utf8]{inputenc}

\begin{document}
本文件中的一些内容。本段没有任何信息
其目的是提供一个关于如何插入空白
和换行的示例。\\
插入换行后，文本不会缩进，
还有几个额外命令可用于换行。 \newline
本段不包含任何信息。我们正在探索
换行。 \hfill \break
并将两个命令结合使用
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Another+line+break+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Butf8%5D%7Binputenc%7D%0A%0A%5Cbegin%7Bdocument%7D%0ASomething+in+this+document.+This+paragraph+contains+no+information+%0Aand+its+purposes+is+to+provide+an+example+on+how+to+insert+white+%0Aspaces+and+lines+breaks.%5C%5C%0AWhen+a+line+break+is+inserted%2C+the+text+is+not+indented%2C+there+%0Aare+a+couple+of+extra+commands+do+line+breaks.+%5Cnewline%0AThis+paragraph+provides+no+information+whatsoever.+We+are+exploring+%0Aline+breaks.+%5Chfill+%5Cbreak%0AAnd+combining+two+commands%0A%5Cend%7Bdocument%7D)

![LineBreaksEx2new.png](/files/f91ab49a2c2a6dd82490dc3cecdf2bb23eb8869f)

这里有三个命令，在示例中效果相同：

* `\\` （两个反斜杠）
* `\newline`
* `\hfill \break`

有关更多换行命令，请参阅 [参考指南](#reference-guide).

## 分页

有两个命令可用于插入分页， `clearpage` 和 `newpage`。下面是一个使用 `clearpage`.

```latex
\documentclass{article}
\usepackage[utf8]{inputenc}

\begin{document}
本文件中的一些内容。本段没有任何信息，而且
其目的是提供一个关于如何插入空白和换行的示例。\\
并且有
插入换行后，文本不会缩进，而且还有
还有几个额外命令可用于换行。 \newline
本段不包含任何信息。我们正在探索
换行。 \hfill \break
并将两个命令结合使用
...
...

\begin{figure}
\centering
\includegraphics[width=3cm]{overleaf-logo}
\caption{Overleaf 标志}
\end{figure}

你好， 这里  有  一些  没有  意义的  文本...
\clearpage
```

![LineBreaksEx3OverleafNew.png](/files/3cfd3e742e5d5d411f439fe4fefac626be4bcd6c)

如果使用命令 `\clearpage` ，并且存在堆叠的浮动元素，例如表格或图形，那么在开始新的一页之前，它们会先被排出。在上面的示例中，同一张图片插入了三次。由于分页是在所有图形显示之前插入的，剩余的图像会先插入到一个空白页中，然后再继续显示断点下方的文本。

如果这不是你所需要的，你可以改用 `\newpage` 。

```latex
\documentclass{article}
\usepackage[utf8]{inputenc}

\begin{document}
\documentclass{article}
\usepackage[utf8]{inputenc}

\begin{document}
本文件中的一些内容。本段没有任何信息，而且
其目的是提供一个关于如何插入空白和换行的示例。\\
并且有
插入换行后，文本不会缩进，而且还有
还有几个额外命令可用于换行。 \newline
本段不包含任何信息。我们正在探索
换行。 \hfill \break
并将两个命令结合使用
...
...

\begin{figure}
\centering
\includegraphics[width=3cm]{overleaf-logo}
\caption{Overleaf 标志}
\end{figure}

你好， 这里  有  一些  没有  意义的  文本...
\newpage
```

![LineBreaksEx4Overleaf.png](/files/046c443cdac27aa5e5bdefef9af6fd200196d909)

在这种情况下，这些图像会被放置在新的一页中，并尽量适应文本流。

[在 Overleaf 中打开](https://www.overleaf.com/project/new/template/19338?id=65200057\&templateName=\&latexEngine=\&texImage=texlive-full%3A2020.1\&mainFile=)

## 水平空白

可以使用 `\hspace`.

```latex
可以手动插入水平 \hspace{1cm} 空白。很有用
于控制图片布局的细微调整。

左侧 \hfill 右侧
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=\&snip_name=Horizontal+spaces\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%0AHorizontal+%5Chspace%7B1cm%7D+spaces+can+be+inserted+manually.+Useful+%0Ato+control+the+fine-tuning+in+the+layout+of+pictures.%0A%0ALeft+Side+%5Chfill+Right+Side%0A%0A%5Cend%7Bdocument%7D)

![LineBreaksEx5.png](/files/c46aeddacb032c59382fb62002a348a04527953a)

在这个示例中，有两个命令可插入水平空白：

**\hspace{1cm}**

插入一个长度为 1cm 的水平空白。该命令也可使用其他 LaTeX 单位。

**\hfill**

插入一个会相应拉伸以填充可用空间的空白。

这些命令 `\hrulefill` 和 `\dotfill` 与……一样 `\hfill` 但它们不是插入空白，而是分别插入一条水平线和一串点。

## 垂直空白

垂直空白的语法与水平空白相同。

```latex
页顶部的文本。页顶部的文本。
页顶部的文本。页顶部的文本。
页顶部的文本。页顶部的文本。
页顶部的文本。

\vspace{5mm} %5mm 垂直空白

这段文字仍然位于顶部，在第一段下方 5mm 处。

\\vfill

页底部的文本。
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=\&snip_name=Vertical+blank+spaces\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%0AText+at+the+top+of+the+page.+Text+at+the+top+of+the+page.+%0AText+at+the+top+of+the+page.+Text+at+the+top+of+the+page.+%0AText+at+the+top+of+the+page.+Text+at+the+top+of+the+page.+%0AText+at+the+top+of+the+page.%0A%0A%5Cvspace%7B5mm%7D+%255mm+vertical+space%0A%0AThis+text+still+at+the+top%2C+5mm+below+the+first+paragraph.%0A%0A%5Cvfill%0A%0AText+at+the+bottom+of+the+page.%0A%0A%5Cend%7Bdocument%7D)

![LineBreaksEx6.png](/files/395d9a58fa66372c9681edec4d45b63b7933fbc0)

让我们看看插入垂直空白的两个命令。

**\vspace{5mm}**

插入一个长度为 5mm 的垂直空白。该命令也可使用其他 LaTeX 单位。

**\\\vfill**

插入一个会相应拉伸以填满可用垂直空间的空白。这就是为什么“页底部的文本。”这一行会被移到底部，其余空间会被填满。

另外还有三个常用于插入垂直空白的命令

**\smallskip**

根据其他因素（文档类型、可用空间等），增加 3pt 的空白，误差为正负 1pt

**\\\medskip**

根据其他因素（文档类型、可用空间等），增加 6pt 的空白，误差为正负 2pt

**\bigskip**

根据其他因素（文档类型、可用空间等），增加 12pt 的空白，误差为正负 4pt

## 参考指南

**其他换行命令**

* ```latex
   \\*
  ```

  （两个反斜杠和一个星号）

在命令所在处换行，并且额外禁止在强制换行后分页。

* ```latex
   \break
  ```

在不填充当前行的情况下换行。如果你不自己填满这一行，格式会非常糟糕。要填满这一行，我们可以如下使用它。

* ```latex
   \hfill\break
  ```

这会产生与 *\newline* 和 *\\\\*.

此外，LaTeX 还提供了以下用于换行的高级选项。

* ```latex
   \linebreak[number]
  ```

它会在命令所在处换行。 *number* 作为参数提供的值表示该命令的优先级，范围从 0 到 4。（0 表示它很容易被忽略，4 表示无论如何都要执行。）使用此换行选项时，LaTeX 会尽力生成最佳的换行效果。

## 进一步阅读

更多信息请参见：

* [LaTeX 中的长度](/latex/zh-cn/ge-shi-hua/01-lengths-in-latex.md)
* [段落和换行](/latex/zh-cn/latex-ji-chu/02-paragraphs-and-new-lines.md)
* [段落格式](/latex/zh-cn/ge-shi-hua/04-articles-how-to-change-paragraph-spacing-in-latex.md)
* [文本对齐](/latex/zh-cn/ge-shi-hua/06-text-alignment.md)
* [加粗、斜体和下划线](/latex/zh-cn/latex-ji-chu/03-bold-italics-and-underlining.md)
* [列表](/latex/zh-cn/latex-ji-chu/04-lists.md)
* [单面和双面文档](/latex/zh-cn/ge-shi-hua/08-single-sided-and-double-sided-documents.md)
* [多栏](/latex/zh-cn/ge-shi-hua/09-multiple-columns.md)
* [LaTeX2ε 不那么简短的介绍](http://www.ctan.org/tex-archive/info/lshort/)


---

# 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/ge-shi-hua/05-line-breaks-and-blank-spaces.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.
