我有以下 MWE:
\documentclass{article}
\usepackage{enumitem, kantlipsum}
\begin{document}
\begin{enumerate}
\item[Item 1] \kant[1]
\item[Item 2] \kant[2-3]
\item[Item 3] \kant[4]
\end{enumerate}
\end{document}
对于用红色标记的单个项目\itemsep
,我希望列表使用与默认项目不同的(较小的)值。我知道如何定义自定义项目,但如何让它使用与环境\itemsep
其他部分不同的值enumerate
?
答案1
插入负片\vspace
以删除项目分隔符(实际上包括\parskip
)。
\documentclass{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[itemsep=\baselineskip]
\item[Item 1] Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Maecenas semper mattis eros eget malesuada. Curabitur ut dolor metus.
Vivamus condimentum nisi eu tincidunt aliquet.
\item[Item 2] Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Maecenas semper mattis eros eget malesuada. Curabitur ut dolor metus.
Vivamus condimentum nisi eu tincidunt aliquet.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Maecenas semper mattis eros eget malesuada. Curabitur ut dolor metus.
Vivamus condimentum nisi eu tincidunt aliquet.
\vspace{\dimexpr-\itemsep-\parskip}% Remove item separation
\item[Item 3] Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Maecenas semper mattis eros eget malesuada. Curabitur ut dolor metus.
Vivamus condimentum nisi eu tincidunt aliquet.
\item[Item 4] Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Maecenas semper mattis eros eget malesuada. Curabitur ut dolor metus.
Vivamus condimentum nisi eu tincidunt aliquet.
\end{enumerate}
\end{document}
您也可以使用
\vspace{\dimexpr-\itemsep-\parskip+3pt}
如果您希望间隙为3pt
。会删除列表在新的(不是第一个)-\itemsep-\parskip
顶部插入的任何空间,因此添加长度应该准确地显示为s 之间的间隙。\item
\item
\item
答案2
您可以使用two
(或更多)枚举环境和resume
选项来实现这一点:
\documentclass{article}
\usepackage{enumitem, kantlipsum}
\begin{document}
\begin{enumerate}[noitemsep]
\item[Item 1] \kant[1]
\item[Item 2] \kant[2-3]
\end{enumerate}
\begin{enumerate}[resume, before=\leavevmode\vspace*{-\dimexpr\baselineskip+\topsep+\partopsep\relax}]
\item[Item 3] \kant[4]
\item[Item 4] \kant[5]
\end{enumerate}
\end{document}
答案3
编辑:
一个简单的解决方案是在项目段落末尾使用\\[-\myitemsep]
,以便减少垂直空间:
\documentclass{article}
\usepackage{enumitem, kantlipsum}
\usepackage{calc}% <-- added
\newlength\myitemsep% <-- added
\setlength\myitemsep{\baselineskip+\itemsep}% <-- added
\begin{document}
\begin{enumerate}
\item[Item 1] \kant[1]
\item[Item 2] first item paragraph first item paragraph first item paragraph first item paragraph first item paragraph first item paragraph first item paragraph item paragraph item paragraph item paragraph item paragraph
second item paragraph second item paragraph second item paragraph second item paragraph second item paragraph second item paragraph second item paragraph second item paragraph
\\[-\myitemsep]% <-- added
\item[Item 3] \kant[4]
\item[Item 4] \kant[5]
\end{enumerate}
\end{document}