我用enumitem 包修改与列表相关的空间量。此包可以轻松修改的选项之一是topsep
。但是,此变量控制列表前后的垂直空间。我可以手动在列表后添加一些空间,但这只是一个技巧。
\documentclass{article}
\usepackage{enumitem}
\setlist{noitemsep}
\begin{document}
I like the lack of vertical space between the end of this paragraph and the beginning of the following list.
\begin{itemize}[topsep=0pt]
\item Item 1
\item Item 2
\end{itemize}
I don't like the lack of vertical space between the end of the previous list and the beginning of this paragraph.
I don't like the lack of vertical space between the end of this paragraph and the beginning of the following list.
\begin{itemize}
\item Item 1
\item Item 2
\end{itemize}
I like the vertical space between the end of the previous list and the beginning of this paragraph.
To get the best of both worlds,
I use a baseline skip after the list.
\begin{itemize}[topsep=0pt]
\item Item 1
\item Item 2
\end{itemize}
\vspace*{\baselineskip}
Now there is a good amount of space between the end of the previous list and the beginning of this paragraph,
but a bit too much and achieved via a ``hack''.
\end{document}
问题
我如何使用这个包来分别修改前后的空间量?
答案1
您可以使用before=<code>
and/orafter=<code>
来放置空格/一些 latex 代码。如果您使用
\setlist{nosep,after=\vspace{\baselineskip}}
我们得到
代码:
\documentclass{article}
\usepackage{enumitem}
\setlist{nosep,after=\vspace{\baselineskip}}
\begin{document}
I like the lack of vertical space between the end of this paragraph and the beginning of the following list.
\begin{itemize}
\item Item 1
\item Item 2
\end{itemize}
I don't like the lack of vertical space between the end of the previous list and the beginning of this paragraph.
I don't like the lack of vertical space between the end of this paragraph and the beginning of the following list.
\begin{itemize}
\item Item 1
\item Item 2
\end{itemize}
I like the vertical space between the end of the previous list and the beginning of this paragraph.
To get the best of both worlds,
I use a baseline skip after the list.
\begin{itemize}
\item Item 1
\item Item 2
\end{itemize}
%\vspace*{\baselineskip}
Now there is a good amount of space between the end of the previous list and the beginning of this paragraph,
but a bit too much and achieved via a ``hack''.
\end{document}
如果要为某个itemize
环境覆盖此设置,请使用
\begin{itemize}[after=]