Context: I want to treat lists (itemize, enumerate, and description) just like regular text for what regards vertical spacing. Namely:
- If the list starts a paragraph, insert a vertical
\parskip
beforehand — no vertical spacing otherwise;- No vertical spacing between items of the list;
- If the list ends a paragraph, insert a vertical
\parskip
afterwards — no vertical spacing otherwise.
I have notably used information found in \topsep, \itemsep, \partopsep and \parsep - what does each of them mean.
Requirement #1 is solved with \setlist{topsep=-\parskip,partopsep=\parskip}
.
Requirement #2 is solved with \setlist{noitemsep}
.
Problem: There remain two issues with Requirement #3:
- A vertical space is added after the list if the latter starts a paragraph, even if this list is immediately followed by text. (I.e. there is no such thing as an idependent
parbottomsep
length). - If a new paragraph starts after the list, this paragraph is not preceded with a
\parskip
.
Question:
How to comply with Requirement #3?
(I currently use manual patches — see MWE below — but it is of course not satisfactory.)
MWE
\documentclass[parskip=half]{scrartcl}
\usepackage{enumitem}
\setlist{%
topsep=-\parskip,
partopsep=\parskip,
noitemsep,
}
\begin{document}
This sentence is a paragraph on its own; there is thus a vertical parskip prior next paragraph.
Following list is \emph{within} a paragraph, with preceding and appended text.
\begin{itemize}
\item One,
\item Two,
\begin{itemize}
\item Two and a half;
\item Almost three.
\end{itemize}
\item Three.
\end{itemize}
This text is appended to the previous list.
However, following list starts a new paragraph on its own.
\begin{enumerate}
\item Did you notice the vertical spacing preceding this list?
\item Two,
\begin{enumerate}
\item Two and a half;
\item Almost three.
\end{enumerate}
\item Three.
\end{enumerate}
% \vspace{-\parskip} %quick and dirty solution
\textbf{There shouldn't be a vertical spacing here.}
This text is appended to the previous list too.
And finally, a list with preceding text only.
\begin{itemize}
\item One,
\item Two,
\begin{itemize}
\item Two and a half;
\item Almost three.
\end{itemize}
\item Three.
\end{itemize}
% \null\par %quick and dirty solution
\textbf{There should be a vertical spacing here.}
This is a new paragraph.
It should thus be preceded with parskip.
\end{document}