0

Here's a MWE:

\documentclass{book}
\usepackage{geometry}
\geometry{paperwidth=127mm,paperheight=203mm,totalwidth=92mm,totalheight=165mm}
\usepackage{lipsum}
\linespread{1.2}
\begin{document}
\vspace*{5cm}
\lipsum[1][1-8]

\lipsum[1][1-8]

\lipsum[1][1-12]

\lipsum[1][1-9]

\lipsum[1][1-10]

\lipsum[1][1-10]

\lipsum[1][1-12]

\lipsum[1][1-12]

\lipsum[1][1-4]
\end{document}

My point is that there's a lot more vertical space between the paragraphs on page 2 than on page 1 or 3. If I look at pages 2 and 3 side by side, I think that the difference is annoying.

However, it seems pretty obvious that this could be fixed by moving the first line of page 3 to the end of page 2 without creating orphans or widows and without exceeding the available height for page 2. Why doesn't TeX do that?

4
  • 2
    Typically \parskip uses (expandable) glue. Use \the\parskip for details. Try using \raggedbottom to make vertical expansion unnecessary. Oct 2, 2020 at 16:13
  • This is for a book. I can't use \raggedbottom.
    – Frunobulax
    Oct 2, 2020 at 16:42
  • Is tex.stackexchange.com/questions/401778/… sort of where you are headed? Note: a better solution might be possible using \pagetotal and \pagegoal. Oct 2, 2020 at 17:10
  • Not really. I think the solution I describe below is fine with me, though. Thanks.
    – Frunobulax
    Oct 2, 2020 at 17:32

2 Answers 2

1

If you insert \tracingpages=1 you can see in the log file:

%% goal height=469.47046, max depth=5.0
% t=10.0 g=469.47046 b=10000 p=0 c=100000#
% t=24.39996 g=469.47046 b=10000 p=150 c=100000#
% t=38.79993 g=469.47046 b=10000 p=0 c=100000#
% t=53.19989 plus 1.0 g=469.47046 b=10000 p=150 c=100000#
% t=67.59985 plus 1.0 g=469.47046 b=10000 p=0 c=100000#
% t=81.99982 plus 1.0 g=469.47046 b=10000 p=0 c=100000#
% t=96.39978 plus 1.0 g=469.47046 b=10000 p=0 c=100000#
% t=110.79974 plus 1.0 g=469.47046 b=10000 p=100 c=100000#
% t=125.1997 plus 1.0 g=469.47046 b=10000 p=0 c=100000#
% t=139.59967 plus 1.0 g=469.47046 b=10000 p=150 c=100000#
% t=153.99963 plus 1.0 g=469.47046 b=10000 p=0 c=100000#
% t=168.3996 plus 2.0 g=469.47046 b=10000 p=150 c=100000#
% t=182.79956 plus 2.0 g=469.47046 b=10000 p=0 c=100000#
% t=197.19952 plus 2.0 g=469.47046 b=10000 p=0 c=100000#
% t=211.59949 plus 2.0 g=469.47046 b=10000 p=0 c=100000#
% t=225.99945 plus 2.0 g=469.47046 b=10000 p=100 c=100000#
% t=240.39941 plus 2.0 g=469.47046 b=10000 p=0 c=100000#
% t=254.79938 plus 2.0 g=469.47046 b=10000 p=0 c=100000#
% t=269.19934 plus 2.0 g=469.47046 b=10000 p=150 c=100000#
% t=283.5993 plus 2.0 g=469.47046 b=10000 p=0 c=100000#
% t=297.99927 plus 3.0 g=469.47046 b=10000 p=150 c=100000#
% t=312.39923 plus 3.0 g=469.47046 b=10000 p=0 c=100000#
% t=326.7992 plus 3.0 g=469.47046 b=10000 p=0 c=100000#
% t=341.19916 plus 3.0 g=469.47046 b=10000 p=0 c=100000#
% t=355.59912 plus 3.0 g=469.47046 b=10000 p=100 c=100000#
% t=369.99908 plus 3.0 g=469.47046 b=10000 p=0 c=100000#
% t=384.39905 plus 3.0 g=469.47046 b=10000 p=0 c=100000#
% t=398.79901 plus 3.0 g=469.47046 b=10000 p=150 c=100000#
% t=413.19897 plus 3.0 g=469.47046 b=10000 p=0 c=100000#
% t=427.59894 plus 4.0 g=469.47046 b=10000 p=150 c=100000#
% t=441.9989 plus 4.0 g=469.47046 b=10000 p=0 c=100000#
% t=456.39886 plus 4.0 g=469.47046 b=3482 p=0 c=3482#
% t=470.79883 plus 4.0 g=469.47046 b=* p=0 c=*

Underfull \vbox (badness 3482) has occurred while \output is active []
 [2]

This transcript shows internal parameters after each line of the page. t means the size of total material accumulated to the page at the end of each line. You can see, that the first line has size 10pt (from top of the page to its baseline), the first plus second lines have size 24.399, etc. The fourth line is first line of a new paragraph. The \parskip with the value 0pt plus 1pt is inserted before this line, so we can see, that t includes stretchability by "plus 1 pt" now.

The parameter g (goal) means goal, the size of the page to be filled. The c parameter means cost, i.e. something like penalty if the point is chosen as break-point. You can see, that c is always 100000, it means. a maximal cost. If the break is here then underfull vbox is warned. At the last but one line the c is 3482, it means that there is more reasonable breaking point. And the last line reports c=*, it means that t is greater than g and overfull is here. Now, TeX choose the minimal c and here is the real page break. You can see that g minus t is almost one line height. This space must be divided between paragraphs where stretchability "plus 1pt" are allowed. But we have accumulated only "plus 4pt" on this page because the four beginning of paragraphs are here. The page must be stretched by t minus g using only "plus 4pt" stretchability, this leads to Underfull vbox warning.

Your problem is that your \vsize is less by only 1 pt than an ideal size in which the last line reported in our transcript does'n cause an overfull page.

0

I found something in the Mittelbach/Goossens book (which I admit is on my bookshelf but rarely looked at). I'm not sure if this is the "best" way to do it but it seems to fix my problem. Use this at the beginning of the document:

\newcounter{tempc} \newcounter{tempcc}
\setlength\textheight{165mm-\topskip}
\setcounter{tempc}{\textheight}
\setcounter{tempcc}{\baselineskip}
\setcounter{tempc}{\value{tempc}/\value{tempcc}}
\setlength\textheight{\baselineskip*\value{tempc}+\topskip}

You also need to use the calc package for this to work.

EDIT: As David Carlisle suggested, the heightrounded option of the geometry package provides a similar solution.

3
  • 1
    the geometry package will do that for you Oct 2, 2020 at 16:58
  • @DavidCarlisle Are you referring to the heightrounded option (that I just found in the documentation)? It seems the Mittelbach/Goossens solution produces a more pleasing result. It is also my understanding that heightrounded might enlarge textheight which is not what I want.
    – Frunobulax
    Oct 2, 2020 at 17:17
  • 2
    Probably. I couldn't remember the name was going to check:-) either way the intention is to ensure that textheight-topskip is a multiple of \baselineskip Oct 2, 2020 at 17:23

You must log in to answer this question.

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