我正在排版一份文档,但面临一些限制:
- 该
.tex
文件包含unicode字符,因此我需要使用支持unicode的引擎(例如XeLaTeX)来编译它。 - 段落需要用垂直间隙而不是缩进来划分。我想使用
parskip
包来尽可能轻松地实现此要求。 - 文档包含许多枚举列表,这些列表的标签需要遵循非默认方案,例如,使用小写字母标签表示最外层的嵌套级别,而不是通常的阿拉伯数字标准。我想使用
enumitem
包来尽可能轻松地实现此要求。
我遇到了一个问题。鉴于我使用垂直间距而不是缩进来直观地划分段落,我还想稍微调整一下enumitem
在进入和退出枚举环境时处理垂直间距的方式,以便为读者提供一个微妙的视觉提示,表明给定的列表属于这段落而不是那段落。
我发现了四种令我感兴趣的垂直间距不同情况:
- 案例 0:
parskip
包装在从一个段落过渡到另一个段落时通常提供的标准垂直间距 - 情况1:从段落正文跳转到列表第一项时的垂直间距
- 案例 2:从列表的最后一项跳转回同一段落的正文续篇时的垂直间距
- 案例三:从列表的最后一项跳转到新段落时的垂直间距
由于案例 1 和案例 2 都是发生的转换之内对于给定的段落,我希望这些间距相对较小:大约与普通行距相同大小(即,大约为 的大小\baselineskip
)或可能稍大一点。目的是从视觉上提示读者我们仍然在同一个段落内操作。
相反,情况 0 和情况 3 都是发生之间段落。因此,我希望这些间距彼此大小大致相同,并且比情况 1 和 2 稍大一些。
下面,我创建了一个最小的工作示例:
- 案例 1 和案例 2 的间距大小与我在实际文档中使用的间距大致相同
- 夸大 Case 0 间距,以便更容易看到其效果
% Basic document setup
\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\geometry{letterpaper}
% Use this package because I need paragraphs delineated with vertical spacing
% instead of indents
\usepackage[skip=5ex]{parskip}
% Use this package because I want non-default settings for both the item
% labels as well as how they are spaced relative to one another
\usepackage{enumitem}
\setlist[enumerate]{label = (\alph*),
ref = (\alph*),
topsep = -4ex,
parsep = 0ex,
itemsep = 0.5ex,
partopsep = 20ex % Large value to show it has no impact in this example
}
% Use this because my document contains unicode characters, and compiles with
% the XeLaTex engine
\usepackage{fontspec}
\setmainfont{Times New Roman}
\begin{document}
This is an ordinary paragraph. It contains no lists. It's sole purpose is to illustrate ordinary interparagraph spacing, as controlled by package \texttt{parskip}. Below this is a Case 0 vertical space.
This is a paragraph that contains an enumeration list inside the body of the paragraph--the enumerate environment is bracketed by same-paragraph text both before and immediately afterward. Below this line is a Case 1 vertical space: i.e., the space between some ordinary paragraph text and the first item of the list.
\begin{enumerate}
\item Here are some unicode characters: α, β, γ
\item Here's a second list item
\item Below this item is a Case 2 vertical space: i.e., the space between the final item in a list and the continuation of the paragraph.
\end{enumerate}
Here is a continuation of paragraph two. Below this line is another Case 0 vertical space, followed by a third paragraph.
Here is a third paragraph. It contains an enumeration list at the \emph{end} of the paragraph. Below this line is another Case 1 vertical space.
\begin{enumerate}
\item Here are some more unicode characters: δ and ε
\item Here's a second list item
\item Below this is a Case 3 vertical space: i.e., the space between a final list item and the start of a \emph{new} paragraph.
\end{enumerate}
This is a fourth and final paragraph. In my example, it's squished up against the third paragraph, because the Case 3 spacing between them is too small. How do I adjust the spacing parameters of the \texttt{parskip} and \texttt{enumitem} packages to make Case 3 look more like Case 0--but without affecting Case 1 or Case 2?
\end{document}
我的问题:如何调整parskip
和enumitem
包的垂直间距参数,使案例 3 看起来更像案例 0,而不影响我已经为案例 1 和 2 设置的值?或者,如果这两个包从根本上不兼容,那么在不弄乱文档其他部分(例如,目录、图形标题等)的垂直间距的情况下,实现这种间距约定的最佳方法是什么?
答案1
通常,列表以垂直模式结束,因此根本看不到后面的空白行,但是您可以强制返回水平模式,以便开始一个段落,然后后面的文本将流入该段落,但空白行将结束隐式段落并导致添加额外的\parskip
粘合。
% Basic document setup
\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\geometry{letterpaper}
% Use this package because I need paragraphs delineated with vertical spacing
% instead of indents
\usepackage[skip=5ex]{parskip}
% Use this package because I want non-default settings for both the item
% labels as well as how they are spaced relative to one another
\usepackage{enumitem}
\setlist[enumerate]{label = (\alph*),
ref = (\alph*),
topsep = -4ex,
parsep = 0ex,
itemsep = 0.5ex,
partopsep = 20ex , % Large value to show it has no impact in this example
after=\aftergroup\leavevmode\aftergroup\ignorespaces
}
% Use this because my document contains unicode characters, and compiles with
% the XeLaTex engine
\usepackage{fontspec}
\setmainfont{Times New Roman}
\begin{document}
This is an ordinary paragraph. It contains no lists. It's sole purpose is to illustrate ordinary interparagraph spacing, as controlled by package \texttt{parskip}. Below this is a Case 0 vertical space.
This is a paragraph that contains an enumeration list inside the body of the paragraph--the enumerate environment is bracketed by same-paragraph text both before and immediately afterward. Below this line is a Case 1 vertical space: i.e., the space between some ordinary paragraph text and the first item of the list.
\begin{enumerate}
\item Here are some unicode characters: α, β, γ
\item Here's a second list item
\item Below this item is a Case 2 vertical space: i.e., the space between the final item in a list and the continuation of the paragraph.
\end{enumerate}
Here is a continuation of paragraph two. Below this line is another Case 0 vertical space, followed by a third paragraph.
Here is a third paragraph. It contains an enumeration list at the \emph{end} of the paragraph. Below this line is another Case 1 vertical space.
\begin{enumerate}
\item Here are some more unicode characters: δ and ε
\item Here's a second list item
\item Below this is a Case 3 vertical space: i.e., the space between a final list item and the start of a \emph{new} paragraph.
\end{enumerate}
This is a fourth and final paragraph. In my example, it's squished up against the third paragraph, because the Case 3 spacing between them is too small. How do I adjust the spacing parameters of the \texttt{parskip} and \texttt{enumitem} packages to make Case 3 look more like Case 0--but without affecting Case 1 or Case 2?
\end{document}
答案2
这段代码能实现你想要的功能吗?
\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\geometry{letterpaper}
% Use this package because I need paragraphs delineated with vertical spacing
% instead of indents
\usepackage[skip=5ex]{parskip}
\newlength{\oldskip}
\setlength{\oldskip}{\parskip}
% Use this package because I want non-default settings for both the item
% labels as well as how they are spaced relative to one another
\usepackage{enumitem}
\setlist[enumerate]{label = (\alph*),
ref = (\alph*)
}
% Use this because my document contains unicode characters, and compiles with
% the XeLaTex engine
\usepackage{fontspec}
\setmainfont{Times New Roman}
\raggedbottom
\begin{document}
This is an ordinary paragraph. It contains no lists. Its sole purpose is to illustrate ordinary interparagraph spacing, as controlled by package \texttt{parskip}. Below this is a Case 0 vertical space.
This is a paragraph that contains an enumeration list inside the body of the paragraph--the enumerate environment is bracketed by same-paragraph text both before and immediately afterward. Below this line is a Case 1 vertical space: i.e., the space between some ordinary paragraph text and the first item of the list.
\begin{enumerate}[label=(\alph*), ref=(\alph*), nosep, itemsep=0.5ex, topsep =0.5ex, before={\parskip = 0pt}, after =\vspace*{-\oldskip}]
\item Here are some unicode characters: $ α, β, γ $
\item Here's a second list item
\item Below this item is a Case 2 vertical space: i.e., the space between the final item in a list and the continuation of the paragraph.
\end{enumerate}
Here is a continuation of paragraph two. Below this line is another Case 0 vertical space, followed by a third paragraph.
Here is a third paragraph. It contains an enumeration list at the \emph{end} of the paragraph. Below this line is another Case 1 vertical space.
\begin{enumerate}[label=(\alph*), ref=(\alph*), nosep, itemsep=0.5ex, topsep =0.5ex, before={\parskip = 0pt}]%,
\item Here are some more unicode characters: $ δ $ and $ ε $
\item Here's a second list item
\item Below this is a Case 3 vertical space: i.e., the space between a final list item and the start of a \emph{new} paragraph.
\end{enumerate}
This is a fourth and final paragraph. In my example, it's squished up against the third paragraph, because the Case 3 spacing between them is too small. How do I adjust the spacing parameters of the \texttt{parskip} and \texttt{enumitem} packages to make Case 3 look more like Case 0--but without affecting Case 1 or Case 2?
\end{document}