> 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/geng-duo-zhu-ti/37-line-breaks-and-blank-spaces-es.md).

# 换行和空白 es

不建议打断 LaTeX 文档的正常排版流程，除非你正在 [编写一个宏](/latex/zh-cn/lei-wen-jian/03-writing-your-own-package.md). 不过，有时需要对文档的整体排版有更多一点控制；因此，本文将说明如何插入手动换行、分页和空白。

## 简介

插入换行很容易，双反斜杠即可完成

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

\begin{document}
本文档中的某些内容。本段不包含任何信息
其目的在于提供一个如何插入空白
空格和换行的示例。\\
当插入换行时，文本不会缩进，存在
还有几个额外的换行命令。
\end{document}
```

![LineBreaksEx1.png](/files/c811d46d361c66bf71c3346a232fe2c6b4dab371)

这并不是插入换行的唯一命令，在 [下一节](#saltos-de-lnea) 还会介绍另外两个。

&#x20; [在 Overleaf 中打开示例](https://www.sharelatex.com/project/new/template?zipUrl=/project/5352974bc52fabc07908a43a/download/zip\&templateName=BreakLines\&compiler=pdflatex)

## 换行

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

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

\begin{document}
本文档中的某些内容。本段不包含任何信息
其目的在于提供一个如何插入空白
空格和换行的示例。\\
当插入换行时，文本不会缩进，存在
还有几个额外的换行命令。 \\newline
本段完全没有提供任何信息。我们正在探讨
换行。 \\hfill \\break
以及组合两个命令
\end{document}
```

![LineBreaksEx2.png](/files/2ae010f5282f94c3acd1432e45cecb083ee7e7f1)

这里有三个命令在示例中起相同的作用：

* `\\` (两个反斜杠)
* `\newline`
* `\\hfill \\break`

如需查看更多用于插入换行的命令，请参阅 [参考指南](#gua-de-referencia).

&#x20; [在 Overleaf 中打开示例](https://www.sharelatex.com/project/new/template?zipUrl=/project/5352974bc52fabc07908a43a/download/zip\&templateName=BreakLines\&compiler=pdflatex)

## 分页

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

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

\begin{document}
本文档中的某些内容。本段不包含任何信息，并且
其目的在于提供一个如何插入空白
和换行的示例。\\
当插入换行时，文本不会缩进，存在
还有几个额外的换行命令。 \\newline
本段完全没有提供任何信息。我们正在探讨
换行。 \\hfill \\break
以及组合两个命令

\begin{figure}
\centering
\\includegraphics[width=4cm]{lion-logo}
\\caption{ShareLaTeX logo}
\end{figure}

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

![LineBreaksEx3.png](/files/fdb74cc25b0543f03048c4ee3daa8cefeb1f8404)

如果使用该命令 `clearpage` 并且如果队列中有浮动元素，例如表格和图形，它们都会在开始新页之前全部插入。在上面的示例中，同一张图片插入了三次。由于在文档中这三张图片出现之前就插入了分页，因此缺失的图片会先被插入到一个空白页中，然后再继续分页之后的文本。

如果这不是你需要的，可以改用 `\newpage` 。看看一个示例：

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

\begin{document}
本文档中的某些内容。本段不包含任何信息，并且
其目的在于提供一个如何插入空白
和换行的示例。\\
当插入换行时，文本不会缩进，存在
还有几个额外的换行命令。 \\newline
本段完全没有提供任何信息。我们正在探讨
换行。 \\hfill \\break
以及组合两个命令

\begin{figure}
\centering
\\includegraphics[width=4cm]{lion-logo}
\\caption{ShareLaTeX logo}
\end{figure}

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

![LineBreaksEx4.png](/files/afb77a3c60ee599da3ac0d2bb0886022d065335c)

在这种情况下，图片会被放置到新页面上，同时尽量适应文本流。

&#x20; [在 Overleaf 中打开示例](https://www.sharelatex.com/project/new/template?zipUrl=/project/5352974bc52fabc07908a43a/download/zip\&templateName=BreakLines\&compiler=pdflatex)

## 水平空白

可使用命令插入任意长度的水平空白 `\\hspace`.

```latex
可以手动插入水平 \\hspace{1cm} 空白。适用于
控制图片排版的微调。

左侧 \\hfill 右侧
```

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

在这个示例中有两个命令会插入空白：

**\\\hspace{1cm}**

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

**\hfill**

插入一个会动态扩展以占据所有可用空间的空白。

命令 `\\hrulefill` 和 `\\dotfill` 与……具有相同的功能 `\hfill` 但它们不是插入空白，而是分别插入一条水平线或一串点。

&#x20; [在 Overleaf 中打开示例](https://www.sharelatex.com/project/new/template?zipUrl=/project/5352974bc52fabc07908a43a/download/zip\&templateName=BreakLines\&compiler=pdflatex)

## 垂直空白

插入垂直空白所使用的语法与水平空白相同。

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

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

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

\\vfill

页面底部的文本。
```

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

让我们看看示例中用于插入垂直空白的两个命令。

**\vspace{5mm}**

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

**\\\vfill**

插入一个会动态扩展以填满页面上所有可用垂直空间的空白。因此，“Text at the bottom of the page.”这一行会被推到页面底部，因为其余空间已经被“填满”了。

还有一些为了方便而常用的其他命令可用于插入垂直空白。

**\\\smallskip**

添加一个大小为 3pt、上下浮动 1pt 的空白，具体取决于其他因素（文档类型、可用空间等）。

**\\\medskip**

添加一个大小为 6pt、上下浮动 2pt 的空白，具体取决于其他因素（文档类型、可用空间等）。

**\\\bigskip**

添加一个大小为 12pt、上下浮动 4pt 的空白，具体取决于其他因素（文档类型、可用空间等）

&#x20; [在 ShareLaTeX 中打开示例](https://www.sharelatex.com/project/new/template?zipUrl=/project/5352974bc52fabc07908a43a/download/zip\&templateName=BreakLines\&compiler=pdflatex)

## 参考指南

**用于插入换行的附加命令**

* ```latex
   \\*
  ```

  (两个反斜杠和一个星号)

在该处插入换行，并且禁止在此换行之后插入分页。

* ```latex
  \\break
  ```

插入一个换行而不填满当前行剩余的可用空间。如果不使用下一行所示的命令来填充剩余空间，这通常会导致非常差的排版效果。

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

产生与……相同的结果 *\newline* 和 *\\\\*.

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

* ```latex
  \\lineabreak[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/geng-duo-zhu-ti/37-line-breaks-and-blank-spaces-es.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.
