2

How to insert a \parskip after lists, but only before a new paragraph?

In the example below, the desired output would be no vertical space after the first list and vertical space after the second list:

enter image description here

What I get instead is no space between the second list and the third paragraph.

\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
  • 1
    topsep is a bit of a misnomer: The parameter applies not only to the space above the list environment, but also to the space below it. By setting this parameter to a negative length number, you pretty much guarantee there will be hardly any whitespace between the list environment and whatever follows it.
    – Mico
    Dec 10, 2023 at 17:34

1 Answer 1

3

You could try something like this, but I'm not sure if it gives the wanted space in all cases. E.g. if a sectioning or another list follows.

\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}

Not the answer you're looking for? Browse other questions tagged .