LaTeX中的段落设置-首行缩进、行间距、段间距等

各种长度参数

参数名称 含义 默认值
\parindent 首行缩进 15.0pt
\leftskip 左缩进 15.0pt
\rightskip 右缩进 15.0pt
\baselineskip 基本行距 12.0pt (字号10pt的1.2倍)
\parskip 段间距 0.0pt plus 1.0pt
\lineskip 见下图
\lineskiplimit 见下图

在这里插入图片描述

各种长度单位

参考《Ishort 6.02》表5.6
在这里插入图片描述
可参考:https://blog.csdn.net/gsgbgxp/article/details/129693747

如何查看当前文档各种长度参数

在latex中可以通过命令 \the 输出各种参数,如下面的代码

The \texttt{\textbackslash parindent} is \the\parindent. \par
The \texttt{\textbackslash leftskip} is \the\leftskip.\par
The \texttt{\textbackslash rightskip} is \the\rightskip.\par
\vspace{2ex}
The approximate font size is \the\fontdimen6\font.\par
\vspace{2ex}
The baseline skip is \the\baselineskip.\par
The line skip is \the\lineskip.\par
The line skip limit is \the\lineskiplimit.\par
\vspace{2ex}
The \verb|\parskip| is \the\parskip.

输出的效果为
在这里插入图片描述

首行缩进

LaTeX \LaTeX LATEX 默认在 \chapter、\section 等章节标题命令之后的第一段不缩进(如果是直接开始文本写作而没有标题,那第一段则有缩进)。如果不习惯这种设定,可以调用 indentfirst 宏包,令第一段的首行缩进照常。
即直接在导言区添加如下宏包即可

\usepackage{indentfirst}

缩进的长度由parindent参数规定。如果想要修改,方法为

\setlength{\parindent}{⟨length⟩}

关于 \indent 和 \noindent

在设置段落首行缩进时,\indent\noindent 两个参数也常被提及。如果需要在某一段
不缩进,可在段落开头使用\noindent 命令。相反地,\indent 命令强制开启一段首行缩进的
段落。在段落开头使用多个\indent 命令可以累加缩进量。
但是,如果是想用这种方式在章节标题命令之后的第一段设置缩进,需要写连续两个\indent
而从第二段开始,默认就是长度为 \parindent 的缩进,此时如果写一个 \indent 也是没有效果的。

以下面设置为例

\documentclass{article}

\begin{document}

The parindent is \the\parindent.

\section{Indent}

\indent \indent This is a paragraph without indentation. This is a paragraph without indentation. This is a paragraph without indentation. 

This is a paragraph with manual indentation. This is a paragraph with manual indentation. This is a paragraph with manual indentation.

\indent This is a paragraph with manual indentation. This is a paragraph with manual indentation. This is a paragraph with manual indentation.

\indent \indent This is a paragraph with manual indentation. This is a paragraph with manual indentation. This is a paragraph with manual indentation.

\noindent This is another paragraph without indentation. This is another paragraph without indentation. This is another paragraph without indentation.

\end{document}

显示效果为
在这里插入图片描述

行距

这部分内容参考《Ishort 6.02》5.3.2节和刘海洋书2.1.4节。
行距最初引起困惑的地方是在于 \setstretch{2}\doublespacing 两个命令实现的效果不一样,从而引发了对行距含义的困惑。
简单说来,缺省的基础行距是1.2 倍字号大小,因此使用 \setstretch{2} 意味着最终行距为 2.4 倍的字号大小,而要想设置成和 \doublespacing 相同的效果,则需要设置为 \setstretch{1.667} ,因为 2/1.2=1.667。
下面详细解释。

行距基本含义

行距的基本含义可以通过下面这张图解释:
在这里插入图片描述
在article等标准文档类来说,默认的因子就是1,而基本行距就是1.2倍字号大小。比如默认字号大小是10pt,那么基本行距就是12pt。对ctexart等中文文档来说,默认因子是1.3,即行距是字号大小的 1.3*1.2=1.56 倍。
之所以会出现 \setstretch{2}\doublespacing 两个命令实现的效果不一样的情况,就是因为\setstretch 设置的是上图中的“因子”,所以在10pt字号大小下 \setstretch{2} 相当于是设置行距为 24pt。而

\singlespacing %单倍行距
\onehalfspacing %一倍半行距
\doublespacing %双倍行距

这几个命令则是指行距相比字号尺寸的倍数。所以说 \doublespacing 相当于是设置行距为 20pt。
如果想要显示效果相同,也就需要设置 \setstretch 的因子为 20pt/12pt=1.667。
一般来说,目前大多数英文latex模板字号为 10pt(对应Word中的五号字体),行距设置为 20pt 是比较好看的,即使用 \doublespacing 即可。但如果字号为 12pt(对应Word中的小四字体),行距可能要设置为 \setstretch{2} 更为合适。具体根据实际情况调整。
需要补充说明的是,Word中的字号如果采用数字的话单位是磅bp,而不是这里的pt。因此在Word中,五号字体对应数字是10.5,而小四字体对应的数字是12。
另外按照刘海洋书中的说法,Word中的n倍行距的概念也是加之于基本行距的因子。但自己没有细究Word中的基本行距概念,毕竟Word在这类问题上过于“灵活”(概念含混不清),一个“是否对齐网格”就把行距的概念全整乱了。

全局行距的设置

上面的 \setstretch 命令需要 setspace 宏包。
其实还可以使用 \linespread{⟨factor⟩} 命令,这个命令可以直接使用,不需要额外宏包。这个命令的详细用法可参考《Ishort》。

局部行距的设置

感觉这种需求应该不是很多。具体参考《Ishort》。注意 \par 命令的位置要在中括号内而不能在中括号外。
在这里插入图片描述
或者应该还可以通过 setspace 提供的环境来实现。
在这里插入图片描述
比如下面的代码

Your introduction goes here! Simply start writing your document and use the Recompile button to view the updated PDF preview. 

\begin{doublespace}
Your introduction goes here! Simply start writing your document and use the Recompile button to view the updated PDF preview. 
\end{doublespace}

\begin{spacing}{2}
Your introduction goes here! Simply start writing your document and use the Recompile button to view the updated PDF preview. 
\end{spacing}

实现的效果为
在这里插入图片描述

段间距

段落间的垂直间距为\parskip,如设置段落间距在0.8ex 到1.5ex 变动:

\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}

如果我们想要人为地增加段落之间的垂直间距,可以在两个段落之间的位置使用\vspace
命令:

A paragraph.

\vspace{2ex}
Another paragraph.

最近更新

  1. TCP协议是安全的吗?

    2024-06-17 01:18:04       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-06-17 01:18:04       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-06-17 01:18:04       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-06-17 01:18:04       18 阅读

热门阅读

  1. Opencv无法自动补全

    2024-06-17 01:18:04       6 阅读
  2. 15分钟面试被5连CALL,你扛得住么?

    2024-06-17 01:18:04       7 阅读
  3. SSH error : no kex alg message

    2024-06-17 01:18:04       7 阅读
  4. Spring (60)Spring WebFlux

    2024-06-17 01:18:04       8 阅读
  5. 数据结构之B树的原理与业务场景

    2024-06-17 01:18:04       8 阅读
  6. Autosar实践——诊断配置(DaVinci Configuration)

    2024-06-17 01:18:04       6 阅读
  7. 2024.06.16 刷题日记

    2024-06-17 01:18:04       4 阅读
  8. linux发展历程

    2024-06-17 01:18:04       6 阅读
  9. atcoder ABC 358-B题详解

    2024-06-17 01:18:04       7 阅读
  10. Qt中的事件循环

    2024-06-17 01:18:04       6 阅读
  11. Linux各目录的作用

    2024-06-17 01:18:04       7 阅读