[Tex/LaTex] How to get uniform spacing between paragraphs across several pages

page-breakingspacingtcolorboxvertical alignment

I am using \flushbottom to get pages of equal height. When I now insert a tcolorbox which is set to be unbreakable such that a page break becomes necessary, only the spaces between paragraphs on the page right before it (third page in the figure) are stretched, while on all pages before the spacing between paragraphs is normal:
enter image description here

I would like to have all spaces between paragraphs on all pages before equally stretched, so that the spacing between paragraphs is uniform across all pages, like this:
enter image description here

Here is my MWE, which contains the examples shown in the figures:

\documentclass[12pt]{book}
\usepackage{parskip}
\usepackage{tcolorbox}
\usepackage{lipsum}

\begin{document}
\paragraph{In this example, we see small gaps between paragraphs on the first two pages and large ones on the third page:}

\lipsum[1-4]
\begin{tcolorbox}
\lipsum[2]
\end{tcolorbox}
\lipsum[1-6]

\begin{tcolorbox}
{}
\lipsum[4]
\end{tcolorbox}
\pagebreak
\setlength{\parskip}{0.5cm plus 0.125cm}
\paragraph{I prefer to have the gaps between paragraphs uniform like this:}
\lipsum[1-4]
\begin{tcolorbox}
\lipsum[2]
\end{tcolorbox}
\lipsum[1-6]

\begin{tcolorbox}
{}
\lipsum[4]
\end{tcolorbox}
\end{document}

Best Answer

Should be easy: Put \raggedbottom just before \begin{document}:

\documentclass[12pt]{book}
\usepackage{parskip}
\usepackage{tcolorbox}
\usepackage{lipsum}

\raggedbottom

\begin{document}
\paragraph{In this example, we see small gaps between paragraphs on the first two pages and large ones on the third page:}

\lipsum[1-4]
\begin{tcolorbox}
\lipsum[2]
\end{tcolorbox}
\lipsum[1-6]

\begin{tcolorbox}
{}
\lipsum[4]
\end{tcolorbox}
\pagebreak
\setlength{\parskip}{0.5cm plus 0.125cm}
\paragraph{I prefer to have the gaps between paragraphs uniform like this:}
\lipsum[1-4]
\begin{tcolorbox}
\lipsum[2]
\end{tcolorbox}
\lipsum[1-6]

\begin{tcolorbox}
{}
\lipsum[4]
\end{tcolorbox}
\end{document}
Related Question