> For the complete documentation index, see [llms.txt](https://ayakaleaf-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://ayakaleaf-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) 还会介绍另外两个。

[在 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).

[在 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)

在这种情况下，图片会放在新页面上，但尽量融入文本的排版流程。

[在 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` 不过它们不是插入空白，而是分别插入一条水平线或一串点。

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

## 垂直空白

插入垂直空白时，语法与水平空白相同。

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

\vspace{5mm} %5mm vertical space

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

\vfill

页面底部的文本。
```

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

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

**\vspace{5mm}**

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

**\vfill**

插入一个会动态扩展以填满页面上所有可用垂直空间的垂直空白。因此，“页面底部的文本。”这一行会被推到最底部，因为剩余空间已经被“填满”了。

还有一些其他命令，出于方便，常用于插入垂直空白。

**\smallskip**

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

**\medskip**

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

**\bigskip**

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

[在 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://ayakaleaf-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.
