原  文:Paragraph formatting
译  者:Xovee
翻译时间:2021年8月12日

LaTeX 段落

LaTeX 默认的段落是比较容易阅读的。当然,有时候你也需要一种不同的段落样式。本文介绍如何更改默认的段落样式,例如行距等。

介绍

改变某些特定元素的长度也许会改变整个文档的结构。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\setlength{\parindent}{4em}
\setlength{\parskip}{1em}
\renewcommand{\baselinestretch}{2.0}

\begin{document}
This is the first paragraph, contains some text to test the paragraph
interlining, paragraph indentation and some other features. Also, is 
easy to see how new paragraphs are defined by simply entering a double 
blank space.

Hello,  here  is  some  text  without  a  meaning.   This  text  should
show what a printed text will look like at this... 
\end{document}

在上面的例子中,我们使用一个空行来分割不同的段落,每个段落的第一行会有缩进,我们还设置了行距和段落之间的间距。

开始一个新的段落

在 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命令即可开始一个新的段落而无需一个空白行。

段落缩进

默认情况下,LaTeX 不对章或者节内的第一个段落进行缩进。之后的段落的缩进大小取决于\parindent

\setlength{\parindent}{4em}

\begin{document}
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.

This is another paragraph, contains some text to test the paragraph
interlining, paragraph indentation and some other features. Also, 
is easy to see how new paragraphs are defined by simply entering a 
double blank space.
...
\end{document}

在这里插入图片描述
\parindent的默认大小取决于文档的类型。你也可以手动设置它。在上面的例子中,每个段落的首行都缩进了4em(一个em的宽度等于字母m的宽度):\setlength{\parindent}{4em}。一般来说,我们推荐在文档的 preamble 中使用这个命令,当然,它也可以放在其他任何地方。

如果你想创建一个没有缩进的段落,在段落的开头使用\noindent命令。如果你希望文档的所有段落都没有缩进,那么将缩进的大小设置为零:\setlength{\parindent}{0pt}

另一方面,如果你想要对一个段落进行缩进,在段落之前使用\indent命令。这个命令只有在\parindent不等于零的时候才有效。

段落间距

决定段落间距的参数为\parskip,它是一个段落和之前的文字的间距大小。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\setlength{\parindent}{4em}
\setlength{\parskip}{1em}

\begin{document}
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...

\end{document}

在这里插入图片描述
在这个例子中,命令\setlength{\parskip}{1em}将段落之间的间距设置为1em

行距

LaTeX 有三个命令来控制行距,下面这个例子重定义了\baselinestretch的长度:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\setlength{\parindent}{4em}
\setlength{\parskip}{1em}
\renewcommand{\baselinestretch}{1.5}

\begin{document}
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...
\end{document}

在这里插入图片描述
上面的例子使用命令\renewcommand{\baselinestretch}{1.5}来将行距设置为默认的 1.5 倍。当然,你可以使用任何其他数字。

此外,还要两个参数可以影响行距:

\baselineskip
控制一个段落中最后两行的最小距离。你可以在 preamble 中改变它的值:\setlength{\baselineskip}{value}

\linespread{value}
设置行距的大小。在这里,value的大小是很有点迷惑的:

Value行距
1.0单倍行距
1.3一点五倍行距
1.6双倍行距

参考指南

段落中长度的原理图:

  • \parindent:段落缩进
  • \parskip:段落间距

在这里插入图片描述

Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐