按照这里的图表:
\topsep、\itemsep、\partopsep 和 \parsep - 它们各自代表什么意思(底部又代表什么意思)?
有名字吗垂直的而不是列表中项目标签与其对应文本之间的水平空间(对于标签较长而\leftmargin
文本被向下推的情况)?
我没有在enumitem 的文档。
答案1
通常,标准列表中项目的标签与后续文本之间没有垂直间距,只有水平间距,即\labelsep
和\itemindent
。
但是,正如 @GuM 所说,您可以手动设置换行符,并自行决定是否添加此类间距。这对于enumerate
和来说很容易,只需在 之后itemize
书写即可。\leavevmode\\[some verticalskip]
\item
不幸的是,它不适用于description
环境。我提出了一个解决方案,即定义一个新Description
环境,为该环境\descriptionlabel
重新定义命令以在基线下方包含一条不可见的规则。此规则的长度是环境的一个可选参数(相当随意的默认值:3mm)。由于xparse
,环境接受第二个可选参数,用于将的集合key = some value
传递给环境description
。
以下是一个例子:
\documentclass{article}%
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[svgnames]{xcolor}
\usepackage{lipsum}
\usepackage{enumitem}
\setlist[description]{leftmargin = 12mm}
\usepackage{xparse}
\NewDocumentEnvironment{Description}{O{3mm}O{}}{\renewcommand*\descriptionlabel[1]{\rule[-#1]{0pt}{#1}\hspace\labelsep
\normalfont\bfseries ##1}\description[style =standard, labelwidth=\textwidth, #2]}{\enddescription}
\begin{document}
‘Force next line’:
\begin{Description}[1.8ex][font=\sffamily\color{FireBrick!60}]
\item[One]\lipsum[4]
\item[And another one] \lipsum[4]
\end{Description}
\end{document}
答案2
我的预测表明,您可能正在使用软件包为环境提供的style=nextline
密钥。如果是这种情况,我建议的解决方法是enumitem
description
一条评论是明显地不适用。但是,由于nextitem
样式不会“框住”标签,因此您可以通过\vspace
在标签中包含适当的命令来实现所需的目的。结尾标签文本,如以下 MWE 所示:
% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.
\usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.
\usepackage{enumitem}
\begin{document}
Preceding text.
\begin{description}[style=nextline,leftmargin=6pc]
\item[A]
The text of the first description.
\item[Short label]
Full description of the second item in the list follows here.
Let's add a few words so that it makes it to the second line.
\item[A somewhat longer label]
Here's the text of the thirs description, or, better, the description of
the third item in the list.
\item[Similar, but with vertical space\vspace{\smallskipamount}]
Replace the argument of \verb|\vspace| (here, \verb|\smallskipamount|)
with any rubber length of your choice.
\item[Abc def ghij\vspace{\smallskipamount}]
If the label is ``short'', then it gets boxed, thus suppressing the
vertical spacing.
\item[Wrong]\leavevmode\\*[\smallskipamount]
The workaround I~suggested in a comment does \emph{not} work as
expexted in the context of a \texttt{description} environment with
\texttt{style=nextline}, neither for ``short'' labels\ldots
\item[And wrong as well]\leavevmode\\*[\smallskipamount]
\ldots nor for ``long'' ones; retrospectively, this is obvious!
\end{description}
Following text.
\end{document}
这是我得到的输出: