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

# 段落與換行

## 簡介

本文介紹 *基本的* LaTeX 段落格式設定，包括如何變更文字對齊方式。更詳細的資訊與更多範例可參見文章 [文字對齊](/latex/zh-tw/ge-shi-hua/06-text-alignment.md) 和 [段落格式設定](/latex/zh-tw/ge-shi-hua/04-articles-how-to-change-paragraph-spacing-in-latex.md).

## 第一個範例

我們先從一個範例開始，藉由將兩個置中的段落寫在一個 `center` 環境中來排版。請注意，新的段落是透過在它們之間插入一個空白行來開始的——雖然這是常用的方法，但並不是開始新段落的唯一方式。

```latex
\begin{center}
範例 1：以下段落（以引號標示）是
使用 center 環境進行置中對齊的範例。

``La\TeX{} 是一種文件製作系統與文件標記
語言。\LaTeX{} 使用 \TeX{} 排版程式來格式化
其輸出，而它本身則以 \TeX{} 巨集語言撰寫。
\LaTeX{} 並不是某個特定（可執行）的排版程式名稱，
而是指一組命令（\TeX{} 巨集），這些命令構成了用來排版 \LaTeX{} 文件的標記
慣例。"
\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/5ca59503a0df65073324b02ffcd817e9711c39d7)

## 開始新段落

如上所述，開始新段落的一種方法是插入一個空白行，但以下程式碼片段展示了另一種使用 `\par` 命令：

```latex
這是第一個段落中的文字。
這是第一個段落中的文字。
這是第一個段落中的文字。\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/27af14acf5e1dc97adae087acdf9d10f06b362e8)

## 段落對齊

預設情況下，LaTeX 中的段落會完全左右對齊，也就是同時貼齊左邊界與右邊界。如果你想要排版一個 *不兩端對齊的* 段落，你可以使用 `flushleft` 或 `flushright` 這些環境。

### flushleft 與 flushright 環境

下一個範例示範如何在 `flushleft` 和 `flushright` 環境中排版段落——關於 `center` 環境的範例請見該章節 [第一個範例](#a-first-example).

```latex
\section*{靠左排版的段落}

\begin{flushleft}
La\TeX{} 是一種文件製作系統與文件標記
語言。\LaTeX{} 使用 \TeX{} 排版程式來格式化
其輸出，而它本身則以 \TeX{} 巨集語言撰寫。
\LaTeX{} 並不是某個特定（可執行）的排版程式名稱，
而是指一組命令（\TeX{} 巨集），這些命令構成了用來排版 \LaTeX{} 文件的標記
用來排版 \LaTeX{} 文件的慣例。
\end{flushleft}

\section*{靠右排版的段落}

\begin{flushright}
La\TeX{} 是一種文件製作系統與文件標記
語言。\LaTeX{} 使用 \TeX{} 排版程式來格式化
其輸出，而它本身則以 \TeX{} 巨集語言撰寫。
\LaTeX{} 並不是某個特定（可執行）的排版程式名稱，
而是指一組命令（\TeX{} 巨集），這些命令構成了用來排版 \LaTeX{} 文件的標記
用來排版 \LaTeX{} 文件的慣例。
\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/d11910b4b8ca436285ba636eee342118f10cf74c)

### \raggedright 和 \raggedleft

除了使用像是 `flushleft`, `flushright` 或 `center` 這類環境之外，另一種替代方式是所謂的「切換」指令：

* `\raggedright`，這是使用 `flushleft` 環境中
* `\raggedleft`，這是使用 `flushright` 環境中
* `\centering`，這是使用 `center` 環境中

這些切換指令會從它們被插入的位置開始改變文字對齊方式，直到文件結尾——除非它們的效果被限制在某個群組內，或被另一個切換指令改變。

在以下範例中， `\raggedright`, `\raggedleft` 和 `\centering` 的效果被局部化，因為它們是在由 `\begingroup ... \endgroup`所建立的群組中使用。此外，請注意每種情況下，段落文字後面都會接著一個空白行，在 `\endgroup` 指令之前，這會觸發 LaTeX 在 `\raggedright`, `\raggedleft` 和 `\centering` 仍然有效的設定下排版該段落。

```latex
\section*{完全左右對齊的排版段落}
\LaTeX{} 並不是某個特定（可執行）的排版程式名稱，而是指一組命令（\TeX{} 巨集），這些命令構成了標記
用來排版 \LaTeX{} 文件的慣例。

\section*{使用 \texttt{\string\raggedright} 排版的段落}

\begingroup
\raggedright
\LaTeX{} 並不是某個特定（可執行）的排版程式名稱，而是指一組命令（\TeX{} 巨集），這些命令構成了標記
用來排版 \LaTeX{} 文件的慣例。

\endgroup

\section*{使用 \texttt{\string\raggedleft} 排版的段落}

\begingroup
\raggedleft
\LaTeX{} 並不是某個特定（可執行）的排版程式名稱，而是指一組命令（\TeX{} 巨集），這些命令構成了標記
用來排版 \LaTeX{} 文件的慣例。

\endgroup

\section*{使用 \texttt{\string\centering} 排版的段落}

\begingroup
\centering
\LaTeX{} 並不是某個特定（可執行）的排版程式名稱，而是指一組命令（\TeX{} 巨集），這些命令構成了標記
用來排版 \LaTeX{} 文件的慣例。

\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/6342a1e740d1d06278a2a79dcea07e18955c4498)

如需更詳細的文字對齊資訊與範例，請參見 [Overleaf 關於文字對齊的文章](/latex/zh-tw/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*{這是一個節}
某個節中的\textbf{第一個段落}，如你所見，沒有縮排。段落中還有更多文字。段落中還有更多文字。

\textbf{第二個段落}。如你所見，這個段落有縮排。段落中還有更多文字。段落中還有更多文字。

\noindent\textbf{第三個段落}。由於使用了 \texttt{\string\noindent}，這一個也沒有縮排。段落中還有更多文字。段落中還有更多文字。現在 \verb|\parindent| 的值是 \the\parindent。段落中還有更多文字。
```

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

### 關於縮排相關指令的注意事項

段落縮排由三個指令控制或影響：

* `\parindent`：一個用來儲存目前段落縮排大小的參數
* `\indent`：此指令的效果取決於它被使用的位置：
  * 在水平模式中（位於段落內或一個 `\hbox`）或數學模式中，它會插入一個寬度為 `\parindent`
  * 在垂直模式中（段落之間或在一個 `\vbox`）中，它會觸發開始一個新的縮排段落
* `\noindent`：此指令的效果也取決於它被使用的位置：
  * 在垂直模式中（段落之間或在一個 `\vbox`）它也會觸發一個新的 *不縮排的* 段落
  * 在水平模式中（位於段落內或一個 `\hbox`）或數學模式中，它沒有任何效果：會被忽略

以下範例展示 `\indent`:

```latex
\documentclass{article}
% 使用 geometry 套件並搭配較小的
% 頁面尺寸來建立本文圖形
\usepackage[paperheight=6in,
   paperwidth=5in,
   top=10mm,
   bottom=20mm,
   left=10mm,
   right=10mm]{geometry}
\begin{document}
\noindent 一個含有一些文字的新段落，接著是一個 \verb|\indent|\indent 指令。下一個是一些行內數學式，其中也有縮排 $y\indent x$。\verb|\indent| 在 \verb|\hbox| 中使用時也能運作，例如 \verb|\hbox{A\indent B}|，其結果為 \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/259f57d438b9aec3c48aa16c4780a6e33011fab6)

## 延伸閱讀

更多資訊請查看

* [段落格式設定](/latex/zh-tw/ge-shi-hua/04-articles-how-to-change-paragraph-spacing-in-latex.md)
* [文字對齊](/latex/zh-tw/ge-shi-hua/06-text-alignment.md)
* [LaTeX 中的長度](/latex/zh-tw/ge-shi-hua/01-lengths-in-latex.md)
* [換行與空白](/latex/zh-tw/ge-shi-hua/05-line-breaks-and-blank-spaces.md)
* [清單](/latex/zh-tw/latex-ji-chu/04-lists.md)
* [粗體、斜體與底線](/latex/zh-tw/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://overleaf-pro.ayaka.space/latex/zh-tw/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.
