![对于 enuimitem 包,某些项目具有独特的不同 \itemsep](https://linux22.com/image/344187/%E5%AF%B9%E4%BA%8E%20enuimitem%20%E5%8C%85%EF%BC%8C%E6%9F%90%E4%BA%9B%E9%A1%B9%E7%9B%AE%E5%85%B7%E6%9C%89%E7%8B%AC%E7%89%B9%E7%9A%84%E4%B8%8D%E5%90%8C%20%5Citemsep.png)
我有以下 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}