[翻译] [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中查看这个例子

延伸阅读

更多信息请参考:

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