> 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/latex-ji-chu/02-paragraphs-and-new-lines.md).

# 段落与换行

## 引言

本文介绍 *基础* LaTeX 段落格式设置，包括如何更改文本对齐方式。更详细的信息以及进一步的示例可参见相关文章 [文本对齐](/latex/zh-cn/ge-shi-hua/06-text-alignment.md) 和 [段落格式](/latex/zh-cn/ge-shi-hua/04-articles-how-to-change-paragraph-spacing-in-latex.md).

## 第一个示例

让我们从一个示例开始：通过将两个居中段落写在一个 `center` 环境中来排版。请注意，在它们之间插入空行就会开始一个新段落——虽然这是一种常用方法，但并不是开始新段落的唯一方式。

```latex
\begin{center}
示例 1：下面的段落（用引号给出）是一个
使用 center 环境进行居中对齐的示例。

``La\TeX{} is a document preparation system and document markup
language. \LaTeX{} uses the \TeX{} typesetting program for formatting
its output, and is itself written in the \TeX{} macro language.
\LaTeX{} is not the name of a particular (executable) typesetting program, but
refers to the suite of commands (\TeX{} macros) which form the markup
conventions used to typeset \LaTeX{} documents.\"
\end{center}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Basic+paragraph+formatting\&snip=%5Cdocumentclass%7Barticle%7D%0A%25+Using+the+geometry+package+with+a+small%0A%25+page+size+to+create+the+article+graphic%0A%5Cusepackage%5Bpaperheight%3D6in%2C%0A+++paperwidth%3D5in%2C%0A+++top%3D10mm%2C%0A+++bottom%3D20mm%2C%0A+++left%3D10mm%2C%0A+++right%3D10mm%5D%7Bgeometry%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Bcenter%7D%0AExample+1%3A+The+following+paragraph+%28given+in+quotes%29+is+an+%0Aexample+of+centred+alignment+using+the+center+environment.+%0A%0A%60%60La%5CTeX%7B%7D+is+a+document+preparation+system+and+document+markup+%0Alanguage.+%5CLaTeX%7B%7D+uses+the+%5CTeX%7B%7D+typesetting+program+for+formatting+%0Aits+output%2C+and+is+itself+written+in+the+%5CTeX%7B%7D+macro+language.+%0A%5CLaTeX%7B%7D+is+not+the+name+of+a+particular+%28executable%29+typesetting+program%2C+but+%0Arefers+to+the+suite+of+commands+%28%5CTeX%7B%7D+macros%29+which+form+the+markup+%0Aconventions+used+to+typeset+%5CLaTeX%7B%7D+documents.%22%0A%5Cend%7Bcenter%7D%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![LaTeX 居中段落示例](/files/02f16718dc8910a8e9ea920472464684b59098fa)

## 开始新段落

如上所述，开始新段落的一种方法是插入空行，但下面的代码片段展示了一种替代方案，它使用 `\par` 命令：

```latex
这是第一段中的文本。
这是第一段中的文本。
This is text contained in the first paragraph.\par
这是第二段中的文本。
这是第二段中的文本。
这是第二段中的文本。
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Starting+a+new+paragraph\&snip=%5Cdocumentclass%7Barticle%7D%0A%25+Using+the+geometry+package+with+a+small%0A%25+page+size+to+create+the+article+graphic%0A%5Cusepackage%5Bpaperheight%3D6in%2C%0A+++paperwidth%3D5in%2C%0A+++top%3D10mm%2C%0A+++bottom%3D20mm%2C%0A+++left%3D10mm%2C%0A+++right%3D10mm%5D%7Bgeometry%7D%0A%5Cbegin%7Bdocument%7D%0AThis+is+text+contained+in+the+first+paragraph.+%0AThis+is+text+contained+in+the+first+paragraph.+%0AThis+is+text+contained+in+the+first+paragraph.%5Cpar%0AThis+is+text+contained+in+the+second+paragraph.+%0AThis+is+text+contained+in+the+second+paragraph.%0AThis+is+text+contained+in+the+second+paragraph.%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![使用 \par 命令创建段落](/files/c1fe5977043d7448b60837995ad95fa11f6f285d)

## 段落对齐

默认情况下，LaTeX 中的段落是两端对齐的，也就是左右两边距都对齐。如果你想排版一个 *不对齐的* 段落，你可以使用 `flushleft` 或 `flushright` 环境。

### flushleft 和 flushright 环境

下一个示例演示在 `flushleft` 和 `flushright` 环境中排版段落——关于 `center` 环境的示例，请参见章节 [第一个示例](#a-first-example).

```latex
\section*{A paragraph typeset flush left}

\begin{flushleft}
La\TeX{} is a document preparation system and document markup
language. \LaTeX{} uses the \TeX{} typesetting program for formatting
its output, and is itself written in the \TeX{} macro language.
\LaTeX{} is not the name of a particular (executable) typesetting program, but
refers to the suite of commands (\TeX{} macros) which form the markup
conventions used to typeset \LaTeX{} documents.
\end{flushleft}

\section*{A paragraph typeset flush right}

\begin{flushright}
La\TeX{} is a document preparation system and document markup
language. \LaTeX{} uses the \TeX{} typesetting program for formatting
its output, and is itself written in the \TeX{} macro language.
\LaTeX{} is not the name of a particular (executable) typesetting program, but
refers to the suite of commands (\TeX{} macros) which form the markup
conventions used to typeset \LaTeX{} documents.
\end{flushright}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Example+of+flushleft+and+flushright\&snip=%5Cdocumentclass%7Barticle%7D%0A%25+Using+the+geometry+package+with+a+small%0A%25+page+size+to+create+the+article+graphic%0A%5Cusepackage%5Bpaperheight%3D6in%2C%0A+++paperwidth%3D5in%2C%0A+++top%3D10mm%2C%0A+++bottom%3D20mm%2C%0A+++left%3D10mm%2C%0A+++right%3D10mm%5D%7Bgeometry%7D%0A%5Cbegin%7Bdocument%7D%0A%5Csection%2A%7BA+paragraph+typeset+flush+left%7D%0A%0A%5Cbegin%7Bflushleft%7D%0ALa%5CTeX%7B%7D+is+a+document+preparation+system+and+document+markup+%0Alanguage.+%5CLaTeX%7B%7D+uses+the+%5CTeX%7B%7D+typesetting+program+for+formatting+%0Aits+output%2C+and+is+itself+written+in+the+%5CTeX%7B%7D+macro+language.+%0A%5CLaTeX%7B%7D+is+not+the+name+of+a+particular+%28executable%29+typesetting+program%2C+but+%0Arefers+to+the+suite+of+commands+%28%5CTeX%7B%7D+macros%29+which+form+the+markup+%0Aconventions+used+to+typeset+%5CLaTeX%7B%7D+documents.%0A%5Cend%7Bflushleft%7D%0A%0A%5Csection%2A%7BA+paragraph+typeset+flush+right%7D%0A%0A%5Cbegin%7Bflushright%7D%0ALa%5CTeX%7B%7D+is+a+document+preparation+system+and+document+markup+%0Alanguage.+%5CLaTeX%7B%7D+uses+the+%5CTeX%7B%7D+typesetting+program+for+formatting+%0Aits+output%2C+and+is+itself+written+in+the+%5CTeX%7B%7D+macro+language.+%0A%5CLaTeX%7B%7D+is+not+the+name+of+a+particular+%28executable%29+typesetting+program%2C+but+%0Arefers+to+the+suite+of+commands+%28%5CTeX%7B%7D+macros%29+which+form+the+markup+%0Aconventions+used+to+typeset+%5CLaTeX%7B%7D+documents.%0A%5Cend%7Bflushright%7D%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![LaTeX 的 flushleft 和 flushright 环境](/files/6686bbba1389ab06b4896765fb2c43bbda72f4ea)

### \raggedright and \raggedleft

使用诸如 `flushleft`, `flushright` 或 `center` 这类环境的另一种方法是所谓的“切换”命令：

* `\raggedright`，它是使用 `flushleft` 环境
* `\raggedleft`，它是使用 `flushright` 环境
* `\centering`，它是使用 `center` 环境

这些切换命令会从它们被插入的位置开始改变文本对齐方式，直到文档末尾——除非它们的效果被限制在一个组内，或者被另一个切换命令改变。

在下面的示例中， `\raggedright`, `\raggedleft` 和 `\centering` 的效果被局部化，因为它们是在由 `\begingroup ... \endgroup`创建的组内使用的。另外，请注意，在每种情况下，段落文本后面都跟着一个空行，然后在 `\endgroup` 命令之前，该命令会触发 LaTeX 对该段落进行排版，同时由 `\raggedright`, `\raggedleft` 和 `\centering` 所应用的设置仍然有效。

```latex
\section*{A fully justified  typeset paragraph}
\LaTeX{} is not the name of a particular (executable) typesetting program, but refers to the suite of commands (\TeX{} macros) which form the markup
conventions used to typeset \LaTeX{} documents.

\section*{A paragraph typeset using \texttt{\string\raggedright}}

\begingroup
\raggedright
\LaTeX{} is not the name of a particular (executable) typesetting program, but refers to the suite of commands (\TeX{} macros) which form the markup
conventions used to typeset \LaTeX{} documents.

\endgroup

\section*{A paragraph typeset using \texttt{\string\raggedleft}}

\begingroup
\raggedleft
\LaTeX{} is not the name of a particular (executable) typesetting program, but refers to the suite of commands (\TeX{} macros) which form the markup
conventions used to typeset \LaTeX{} documents.

\endgroup

\section*{A paragraph typeset using \texttt{\string\centering}}

\begingroup
\centering
\LaTeX{} is not the name of a particular (executable) typesetting program, but refers to the suite of commands (\TeX{} macros) which form the markup
conventions used to typeset \LaTeX{} documents.

\endgroup
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Non-justified+paragraph+formatting+options\&snip=%5Cdocumentclass%7Barticle%7D%0A%25+Using+the+geometry+package+with+a+small%0A%25+page+size+to+create+the+article+graphic%0A%5Cusepackage%5Bpaperheight%3D6in%2C%0A+++paperwidth%3D5in%2C%0A+++top%3D10mm%2C%0A+++bottom%3D20mm%2C%0A+++left%3D10mm%2C%0A+++right%3D10mm%5D%7Bgeometry%7D%0A%5Cbegin%7Bdocument%7D%0A%5Csection%2A%7BA+fully+justified++typeset+paragraph%7D+%0A%5CLaTeX%7B%7D+is+not+the+name+of+a+particular+%28executable%29+typesetting+program%2C+but+refers+to+the+suite+of+commands+%28%5CTeX%7B%7D+macros%29+which+form+the+markup+%0Aconventions+used+to+typeset+%5CLaTeX%7B%7D+documents.%0A%0A%5Csection%2A%7BA+paragraph+typeset+using+%5Ctexttt%7B%5Cstring%5Craggedright%7D%7D%0A%0A%5Cbegingroup%0A%5Craggedright+%0A%5CLaTeX%7B%7D+is+not+the+name+of+a+particular+%28executable%29+typesetting+program%2C+but+refers+to+the+suite+of+commands+%28%5CTeX%7B%7D+macros%29+which+form+the+markup+%0Aconventions+used+to+typeset+%5CLaTeX%7B%7D+documents.%0A%0A%5Cendgroup%0A%0A%5Csection%2A%7BA+paragraph+typeset+using+%5Ctexttt%7B%5Cstring%5Craggedleft%7D%7D%0A%0A%5Cbegingroup%0A%5Craggedleft+%0A%5CLaTeX%7B%7D+is+not+the+name+of+a+particular+%28executable%29+typesetting+program%2C+but+refers+to+the+suite+of+commands+%28%5CTeX%7B%7D+macros%29+which+form+the+markup+%0Aconventions+used+to+typeset+%5CLaTeX%7B%7D+documents.%0A%0A%5Cendgroup%0A%0A%5Csection%2A%7BA+paragraph+typeset+using+%5Ctexttt%7B%5Cstring%5Ccentering%7D%7D%0A%0A%5Cbegingroup%0A%5Ccentering+%0A%5CLaTeX%7B%7D+is+not+the+name+of+a+particular+%28executable%29+typesetting+program%2C+but+refers+to+the+suite+of+commands+%28%5CTeX%7B%7D+macros%29+which+form+the+markup+%0Aconventions+used+to+typeset+%5CLaTeX%7B%7D+documents.%0A%0A%5Cendgroup%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![用于排版 LaTeX 段落的各种对齐选项](/files/ac5cf71c64fa2f36676871c2be84b059b21278da)

有关文本对齐的更详细信息和示例，请参见 [Overleaf 关于文本对齐的文章](/latex/zh-cn/ge-shi-hua/06-text-alignment.md) 其中还讨论了使用 [ragged2e LaTeX 宏包](https://ctan.org/pkg/ragged2e?lang=en) 来排版参差文本并配置断字。

## 段落缩进

默认情况下，新段落通常会缩进一定量，这个量由一个名为 `\parindent` 的参数控制，其值可以使用命令 `\setlength`；例如：

```latex
\setlength{\parindent}{20pt}
```

将 `\parindent` 设为 20pt。你可以通过将 `\parindent` 设为 0pt（或 0mm、0cm 等）来避免缩进，或者使用命令 `\noindent` 在段落开头。默认情况下，LaTeX 不会缩进文档章节中的第一段，如下例所示：

```latex
\setlength{\parindent}{20pt}

\section*{This is a section}
\textbf{First paragraph} of a section which, as you can see, is not indented. This is more text in the paragraph. This is more text in the paragraph.

\textbf{Second paragraph}. As you can see it is indented. This is more text in the paragraph. This is more text in the paragraph.

\noindent\textbf{Third paragraph}. This too is not indented due to use of \texttt{\string\noindent}. This is more text in the paragraph. This is more text in the paragraph.  The current value of \verb|\parindent| is \the\parindent. This is more text in the paragraph.
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Basic+paragraph+indentation\&snip=%5Cdocumentclass%7Barticle%7D%0A%25+Using+the+geometry+package+with+a+small%0A%25+page+size+to+create+the+article+graphic%0A%5Cusepackage%5Bpaperheight%3D6in%2C%0A+++paperwidth%3D5in%2C%0A+++top%3D10mm%2C%0A+++bottom%3D20mm%2C%0A+++left%3D10mm%2C%0A+++right%3D10mm%5D%7Bgeometry%7D%0A%5Cbegin%7Bdocument%7D%0A%5Csetlength%7B%5Cparindent%7D%7B20pt%7D%0A%0A%5Csection%2A%7BThis+is+a+section%7D%0A%5Ctextbf%7BFirst+paragraph%7D+of+a+section+which%2C+as+you+can+see%2C+is+not+indented.+This+is+more+text+in+the+paragraph.+This+is+more+text+in+the+paragraph.%0A%0A%5Ctextbf%7BSecond+paragraph%7D.+As+you+can+see+it+is+indented.+This+is+more+text+in+the+paragraph.+This+is+more+text+in+the+paragraph.+%0A%0A%5Cnoindent%5Ctextbf%7BThird+paragraph%7D.+This+too+is+not+indented+due+to+use+of+%5Ctexttt%7B%5Cstring%5Cnoindent%7D.+This+is+more+text+in+the+paragraph.+This+is+more+text+in+the+paragraph.++The+current+value+of+%5Cverb%7C%5Cparindent%7C+is+%5Cthe%5Cparindent.+This+is+more+text+in+the+paragraph.%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![演示 LaTeX 段落缩进](/files/5143c30f16bbd82385aa1592e9ccf25964cbdfcc)

### 有关缩进相关命令的说明

段落缩进受以下三个命令控制或影响：

* `\parindent`：一个用于存储当前段落缩进大小的参数
* `\indent`：该命令的效果取决于它的使用位置：
  * 在水平模式中（在段落内或在一个 `\hbox`）或数学模式中，它会插入一个宽度为 `\parindent`
  * 在垂直模式中（在段落之间或在一个 `\vbox`）中，它会触发开始一个新的缩进段落
* `\noindent`：该命令的效果同样取决于它的使用位置：
  * 在垂直模式中（在段落之间或在一个 `\vbox`）中，它也会触发一个新的 *非缩进* 段落
  * 在水平模式中（在段落内或在一个 `\hbox`）或数学模式中，它不起作用：它会被忽略

下面的示例演示 `\indent`:

```latex
\documentclass{article}
% Using the geometry package with a small
% page size to create the article graphic
\usepackage[paperheight=6in,
   paperwidth=5in,
   top=10mm,
   bottom=20mm,
   left=10mm,
   right=10mm]{geometry}
\begin{document}
\noindent A new paragraph with some text, then an \verb|\indent|\indent command. Next, some inline math which also has an indent $y\indent x$. \verb|\indent| also works when used in an \verb|\hbox| such as \verb|\hbox{A\indent B}| which produces \hbox{A\indent B}.
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Example+of+the+%5Cindent+command\&snip=%5Cdocumentclass%7Barticle%7D%0A%25+Using+the+geometry+package+with+a+small%0A%25+page+size+to+create+the+article+graphic%0A%5Cusepackage%5Bpaperheight%3D6in%2C%0A+++paperwidth%3D5in%2C%0A+++top%3D10mm%2C%0A+++bottom%3D20mm%2C%0A+++left%3D10mm%2C%0A+++right%3D10mm%5D%7Bgeometry%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cnoindent+A+new+paragraph+with+some+text%2C+then+an+%5Cverb%7C%5Cindent%7C%5Cindent+command.+Next%2C+some+inline+math+which+also+has+an+indent+%24y%5Cindent+x%24.+%5Cverb%7C%5Cindent%7C+also+works+when+used+in+an+%5Cverb%7C%5Chbox%7C+such+as+%5Cverb%7C%5Chbox%7BA%5Cindent+B%7D%7C+which+produces+%5Chbox%7BA%5Cindent+B%7D.%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![演示 \indent 命令](/files/f6f8a5a893c1ec2e9f518eb347872ec20c02d65e)

## 延伸阅读

更多信息请查看

* [段落格式](/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 中的长度](/latex/zh-cn/ge-shi-hua/01-lengths-in-latex.md)
* [换行和空格](/latex/zh-cn/ge-shi-hua/05-line-breaks-and-blank-spaces.md)
* [列表](/latex/zh-cn/latex-ji-chu/04-lists.md)
* [粗体、斜体和下划线](/latex/zh-cn/latex-ji-chu/03-bold-italics-and-underlining.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/latex-ji-chu/02-paragraphs-and-new-lines.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.
