[翻譯] [Overleaf] LaTeX 中的段落和換行

原  文:Paragraphs and new lines
譯  者:Xovee
翻譯時間:2020年5月24日

LaTeX 中的段落和換行

LaTeX 默認的排版已經是很好的了,不過我們有時候也需要一些定製化。本篇文章將會告訴你如何排版段落、改變文字對齊、以及添加空白的行。

介紹

讓我們用一個例子開始:

\begin{center}
Example 1: The following paragraph (given in quotes) is an 
example of Center Alignment using the center environment. 

``LaTeX 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 editing program, but 
refers to the encoding or tagging conventions that are used 
in LaTeX documents".
\end{center}

在這裏插入圖片描述
例子中的兩個段落包含在一個 center 環境之中,這使環境中的文字變成居中對齊。需要注意的是,如果你想開始一個新的段落,你需要添加空白行。這是一種非常自然的做法,當然,還有其他方法。

在 Overleaf 中打開這個例子。

新段落

爲了在 LaTeX 中開始一個新的段落,你需要添加空白行。還有另外一種方法:

This is the text in first paragraph. This is the text in first 
paragraph. This is the text in first paragraph. \par
This is the text in second paragraph. This is the text in second 
paragraph. This is the text in second paragraph.

在這裏插入圖片描述
顯然,\par命令可以創建新的段落。

默認情況下,段落會進行縮進,距離是當前文字大小的 1.5 倍。段落之間也不會有空白的行。下面的章節介紹如何改變段落的樣式。

在 Overleaf 中打開這個例子。

段落對齊(文字對齊)

LaTeX 之中的段落是完全對齊的,例如,文字左邊和右邊的邊距都是對齊的。如果你想改變段落的對齊方式,LaTeX 有如下幾個環境:center, flushleft, flushright(center 環境如上面的例子所示)。

\begin{flushleft}
``LaTeX 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 editing program, but refers 
to the encoding or tagging conventions that are used in LaTeX documents".
\end{flushleft}

在這裏插入圖片描述
flushleft環境會將段落進行左對齊。flushright環境會將段落進行右對齊。

上面提到的環境都基於開關命令:\raggedright\raggedleft\centering(等同於flushleftflushrightcenter)。開關命令會將命令之後的樣式更改爲命令所定義的樣式,而讓之前的樣式保持不變。

更多關於文字對齊的信息請參考這篇文章

在 Overleaf 中打開這個例子。

段落縮進

默認情況下,LaTeX 不會縮進一個章的第一個段落。而該章之後段落的縮進則取決於參數\parindent

\setlength{\parindent}{10ex}
This is the text in first paragraph. This is the text in first 
paragraph. This is the text in first paragraph. \par
\noindent %The next paragraph is not indented
This is the text in second paragraph. This is the text in second 
paragraph. This is the text in second paragraph.

在這裏插入圖片描述
該參數的默認值是由文檔的類所決定的。你可以使用\setlength命令來改變段落的縮進距離。在這個例子中,命令\setlength{\parindent}{10ex}之後的段落將會有這大小爲 10ex 的縮進(ex 等於當前字體下 x 的長度)。

如果你想創建一個沒有縮進的段落,你可以在段落的開頭使用\noindent命令。

如果你想對一個沒有縮進的段落進行縮進,你可以使用\indent命令。需要注意的是,這個命令只有在\parindent不等於 0 的時候纔有效。

更多的例子和信息請參考段落樣式

在Overleaf中查看這個例子

延伸閱讀

更多信息請參考:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章