3

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}
1
  • 1
    I don't think this is possible because TeX can't go back to earlier pages: once a page is shipped out, it's gone. At least, I don't think you can do it without something which changes that output routine. Or maybe you could do something over multiple compilations....?
    – cfr
    Commented Mar 12, 2016 at 14:12

1 Answer 1

2

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}
6
  • 1
    Please read the first sentence of my question: "I am using \flushbottom to get pages of equal height." Using \raggedbottom does generally not result in pages of equal height.
    – emilG
    Commented Mar 12, 2016 at 15:06
  • 1
    Well, there's no \flushbottom in your MWE. So, in that case it is impossible, as cfr pointed out in his comment above, because you cannot have large unbreakable boxes and expect every page to be the same height. It wouldn't even work, if TeX could go back to already shipped out pages. It is like stacking wodden boxes of different sizes on top of each other and requiring each stack to be of equal height.
    – alexkelbo
    Commented Mar 12, 2016 at 15:21
  • 1
    The \flushbottom is automatically set by the book class in my MWE. As my second example shows, it is possible to get the desired result, the question is only whether it can be done automatically. Since cfr suggests doing something over multiple compilations, there is still some hope.
    – emilG
    Commented Mar 12, 2016 at 15:35
  • Ah, sorry, I thought you meant manually. I can't imagine how this should be accomplished even using multiple compilations. If you think about figure and table, these are put at more or less random positions in the document to get an (almost) flushed bottom. But if you want everything in place, I don't think you can do that without rearranging the boxes in the document flow. You could try to put the gray boxes in figure environments and use the float package with option H.
    – alexkelbo
    Commented Mar 12, 2016 at 15:46
  • @alexraasch The book class, in the default twoside mode, uses \flushbottom. However, it's not possible to get uniform spacing unless one resorts to \raggedbottom or adds stretch to \baselineskip.
    – egreg
    Commented Mar 12, 2016 at 15:58

You must log in to answer this question.

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