如何\parskip
在列表后但仅在新段落前插入?
在下面的例子中,所需的输出是第一个列表后没有垂直空格,第二个列表后有垂直空格:
我得到的结果是第二个列表和第三个段落之间没有空格。
\documentclass{article}
\usepackage[skip=\smallskipamount]{parskip}
\usepackage{enumitem}
\setlist{
topsep=-\smallskipamount,
partopsep=\smallskipamount,
parsep=0pt
}
\begin{document}
A paragraph that contains a list
\begin{itemize}
\item item one
\item item two
\end{itemize}
within it.
A paragraph that ends with a list
\begin{itemize}
\item item one
\item item two
\end{itemize}
Another paragraph.
\end{document}
答案1
您可以尝试类似这样的方法,但我不确定它是否在所有情况下都能提供所需的空间。例如,如果后面有一个分区或另一个列表。
\documentclass{article}
\usepackage[skip=\smallskipamount]{parskip}
\usepackage{enumitem}
\setlist{
topsep=-\smallskipamount,
partopsep=\smallskipamount,
parsep=0pt
}
\makeatletter
\AddToHook{env/itemize/after}
{%
\AddToHookNext{para/before}
{\if@endpe\else\vspace{\parskip}\fi}%
}
\makeatother
\begin{document}
\makeatletter A paragraph that contains a list
\begin{itemize}
\item item one
\item item two
\end{itemize}
within it.
A paragraph that ends with a list
\begin{itemize}
\item item one
\item item two
\end{itemize}
Another paragraph.
\end{document}