This question seems to be a duplicate of How to remove the skip after a listing when "\parskip" is increased with "\baselineskip"? but the answer given there doesn’t work although it’s accepted.
How can I set a \parskip
which is only inserted between paragraphs. At the moment my setting leads to an extra vertical space after an [h]
-float or a {lstlisting}
. The latter is not used in my document but illustrates the problem, with display styled environments.* There’s no problem with equations.
\documentclass[fleqn]{book}
\usepackage{parskip}
\usepackage{listings}
\begin{document}
XXXXXXXXXXX XXXXXXXXXX XXXXXXXXXXX XXXXX XXXXX
\begin{equation}
xxxxx = xxxxx
\end{equation}
XXXXXXXXXXX XXXXXXXXXX XXXXXXXXXXX XXXXX XXXXX
XXXXXXXXXXX XXXXXXXXXX XXXXXXXXXXX XXXXX XXXXX
XXXXXXXXXXX XXXXXXXXXX XXXXXXXXXXX XXXXX XXXXX
\begin{lstlisting}
LLLLLLLLLLLLLLLLLLL
\end{lstlisting}
XXXXXXXXXXX XXXXXXXXXX XXXXXXXXXXX XXXXX XXXXX
XXXXXXXXXXX XXXXXXXXXX XXXXXXXXXXX XXXXX XXXXX
XXXXXXXXXXX XXXXXXXXXX XXXXXXXXXXX XXXXX XXXXX
\begin{figure}[h]
\rule{10cm}{2cm}
\end{figure}
XXXXXXXXXXX XXXXXXXXXX XXXXXXXXXXX XXXXX XXXXX
XXXXXXXXXXX XXXXXXXXXX XXXXXXXXXXX XXXXX XXXXX
\end{document}
I could fix this by inserting \vspace{-\parskip}
but this is a bad solution—so MS Word like ;-)
* I’m using an own environment created with mdframed
to get framed boxes.
figure
in order for it to appear shorter by a\parskip
would break if the float ends as a top float. For "non floating listings" you can say\lstset{belowskip=-\parskip}
.\parskip
is “only inserted between paragraphs” why are there uneven spaces around listings—the spacing is correct if I not use a skip but an indent?parskip
package sets\partopskip
to 0pt.