10

I have a document in the book class which has a number of widows and orhans when compiled to pdf. I tried to remove the widows and orphans by using the all option of the nowidow package. It seems to fix the widows/orphans by either shortening or lengthening the page in question, similar to \enlargethispage (I don't know how it is implemented, though). This works pretty well in general, but sometimes the two facing pages of a spread have unequal lengths. I would like to find a solution that ensures the two facing pages have equal lengths, like usual, but allows two different spreads to have different lengths.

Ideally, I would like a global option like in the nowidow package, but that's probably overly optimistic. I am prepared to go through the document, inserting \enlargethispage commands whenever there's a widow/orphan, and the same command on the opposite page of the spread. Is there a smarter way? In particular, is there a way to enlarge/enshorten the two pages of a spread equally?

Edit: Here's my attempt at a MWE. If you compile it, you'll find that a few pairs of facing pages have different lengths. That's what I'm trying to avoid. I found this short article on page makeup in LaTeX which describes a possible solution:

Rule 3 requires that the length of every odd page be the same as the length of >every preceding even page, so you will put pairs of the command >\enlargethispage in your book. (Almost certainly a macro >\enlargethispageandthenext could be written, but as far as I know none exists.)

Would such a macro be hard to make? Could someone give me a hint in the right direction?

\documentclass[11pt, icelandic, leqno]{book}
\usepackage[textwidth=112mm,textheight=190mm, paperwidth=153mm, paperheight=230mm]{geometry}

\usepackage[icelandic]{babel}
\usepackage{lmodern}
%\usepackage[utf8]{inputenc} % if using utf8
\usepackage[T1]{fontenc}
\usepackage[parfill]{parskip}
\setlength{\parindent}{0.5cm}
\setlength{\parskip}{0pt}
\usepackage{microtype}
\usepackage{lipsum}
\frenchspacing

% To avoid headers and footers
% choose one of the below:

%\usepackage[defaultlines=2, all]{nowidow}

%\widowpenalty10000
%\clubpenalty10000

\widowpenalty300
\clubpenalty300

\usepackage{titlesec}
\titleformat{\chapter}[display]
  {\filright\normalfont\LARGE\bfseries}
  {\icelandicordinal{chapter}~\MakeLowercase\chaptertitlename}
  {20pt}
  {\huge}
\usepackage{titleps}
\newpagestyle{myfancy}{
    \sethead[\textsc{\chaptertitle}][][]
    {}{}{\textsc{\thesection{} \sectiontitle{}}}
    \setfoot[\usepage][][]
    {}{}{\usepage}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\title{Title}
\author{Author}
\date{}
\pagestyle{empty}
\begin{document}

\maketitle
\cleardoublepage
\pagestyle{myfancy}

\chapter*{Intro}
\sethead[\textsc{Intro}][][]
{}{}{\textsc{Intro}}

%\lipsum[4-57]
\lipsum[4-8]
\medskip
\lipsum[9-15]
\medskip
\lipsum[16-23]
\medskip
\lipsum[24-35]
\medskip
\lipsum[36-40]
\medskip
\lipsum[41-52]
\medskip
\lipsum[53-57]

\end{document}
7
+100

First, for testing purposes please add to the MWE:

  • The option showframe to the geometry package.
  • Put \usepackage[pagewise]{lineno} in the preamble.
  • Insert \linenumbers after \maketitle.

(After each test, compile twice to see the correct line numbers.)

Well, now analyze with calm what you asking to LaTeX in this MWE:

  1. A not stretchable glue between paragraphs (See What is glue stretching?.) , i.e., \parskip=0pt

  2. Some pages (4, 6, 8 ...) must have extra empty spaces of 4-8 pt, i.e., a \medskip.

  3. Avoid widow/orphans (mean have additional empty spaces equal to \baselineskip in any page).

  4. Maintain the same text length in each page.

Short answer: It makes no sense to want everything and its opposite at the same time!

I am not able to dissect this contradiction as an expert, but let's go by parts, as Jack the Ripper said:

  • 1 + 2: Pages with only text have not any stretchable or shrinkable space. LaTeX can write in your MWE a first line at 11pt of the top margin (test it with \the\topskip), and next lines each 13.6pt (\baselineskip), so the maximum number will be \textheight minus \topskip, minus the depth of the last line (\pagedepth), divided by \baselineskip, roughly: (540.6-11-2.1)/13.6 = 38.78. This mean a total of 39 lines, missing 10.7pt (0.78/textheigh) to reach the bottom margin (nearly a \baselineskip, but insufficient for the 40th line). In contrast, the pages with \medskip are filled thanks to the maximum of 8pt this included rubber length \medskip. Note that 8pt < 10.7pt, but if you look carefully the page seem effectively full filled in spite of \parskip=0pt. LaTeX anyway fill the entire text height with a glue beyond your allowed maximum of 8pt, but warning of being forced to do this to avoid the worse option of fill only the 98% of the page:

    Underfull \vbox (badness 3930) has occurred while \output is active [4]

    In page 5 and others without the \medskip, since the maximum allowed glue is 0pt, a underfull \vbox is even worse:

    Underfull \vbox (badness 10000) has occurred while \output is active [5]

    As a badness of 10000 mean infinitely bad. This mean that LaTeX do not have acceptable places to add some "extra glue" within the text, and therefore chooses left the ending space of 10.7pt.

  • 1 + 3: If the last line is lost (jump to the next page) due to the high penalties for widows/orphans lines, things are still worse, since the above little glues cannot overstretch another 13.6pt. To maintain the text length, the best that could happen in this situation is that widow/orphan badness is not enough to cause any change.

  • 2 + 3 -1: As you do not allowed separation between paragraphs setting \parskip=0pt, this make the parskip package useless at this respect. Just without this restrictive \parskip setting, by default the empty final space can be distributed more or less nicely, although producing still some underfull \vbox warnings, that can be completely cleaned using the parskip package. The cost is sometimes ugly differences in the distance between paragraphs.

Remark: Thus, the best solution is just do not constraint \parskip to 0pt.

(imho, of course ...)

This spacing increase the readability of paragraph (even if there indentation), but sticking to the question, overall maintain the bottom margin consistently. My suggestion is left the dirty tricks as \enlargethispage or \looseness for emergencies in a final draft. Probably in many cases good microtype settings could prevent the use of these commnads.

Beside, it could help the setting of \textheight as \topskip plus exact multiples of the \baselineskip` for the normal font (13.6pt in this MWE), so no glue is needed if a page is filled with the maximum number of lines.

But since the virtue is often the happy medium between two extremes, may be you want allow widow/orphan penalties, left \medskips untouched, insert another vertical elements and moreover, similar small skips between paragraphs. This can be obtained allowing only a little stretching/shrinking glue in \parskip, so that the sum of glues of the 3-6 paragraphs of each page are enough to fill the empty space of nearly 10pt nicely, for example:

\setlength{\parskip}{3pt plus 3pt  minus 1pt}

Just experiment with other values until find the best result for your document (or simpler and better for another reasons, left to parskip package do the work).

If you find definitively awful even the smallest space between paragraphs, there is still one more alternative for add enough "vertical glue": Left \parskip at 0pt or as a rubber length, but play with the \baselineskip in the same way (it can be also a rubber length). For example, try to set something as before the first \lipsum:

\setlength{\baselineskip}{2.85ex  plus .1ex minus .05ex }

With the naked eye the small baseline changes are harder to detect than the uneven separation of paragraphs, but unfortunately note that (a) \baselineskip cannot be adjusted in the preamble, and (b) any font size override this setting (see Is \baselineskip automatically defined?). If there are many font changes in your working document, you can consider redefine \normalsize to set the default baseline skip. For example, adding this in the preamble:

\makeatletter
\renewcommand\normalsize{%
   \@setfontsize\normalsize\@xpt{2.85ex  plus .1ex minus .05ex} 
   \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
   \abovedisplayshortskip \z@ \@plus3\p@
   \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
   \belowdisplayskip \abovedisplayskip
   \let\@listi\@listI}
\makeatother

In other case, if you maintain the \parskip,\texheight and \baselineskip settings of the MWE, then you should renounce to:

  • window/orphan penalties and
  • vertical spaces other that integers of \baselineskip. In a real document the same apply to any other object with a vertical dimension of (tabulars, floats, etc.), including their surrounding vertical spaces (certainly a hard task...). For the sake of the example only (it is a bad idea for a working document), one can redefine \medskip :

     \renewcommand\medskip{\vspace{2\baselineskip}}
     % LaTeX way of say \medskipamount2\baselineskip
    

    Then, if window/orphan lines are allowed, the redefined \medskip not cause any difference in the bottom margin, since now take the same vertical space as two normal lines of text.

Note: I read the cited TUGboat article after first answering, so I realize that have I put the focus in allow the "TeX approach" (\parskip glues) and the "extra leading between lines" approach (\baselineskip glues), however, is inexcusable to forget at least a third approach of this excellent article: the traditional but still valid rewriting of the text.

3

The addlines package (uses afterpage, so use with care), provides the \addlines command to add one extra baselineskip's worth of space to the current and facing page. It must be placed in the text on a verso page, obviously, but will give an error if not.

Use \addlines[2] or \addlines[-1], etc., according to your needs.

An example document (straight from the documentation):

\documentclass[twoside]{article}
\usepackage[a5paper,width=30em,lines=30]{geometry}
\usepackage{lipsum}
\usepackage{addlines}
\begin{document}

\lipsum[1-5]

\emph{Here is the command used correctly on an even page.}

\addlines

\lipsum[6-15] 
\emph{Here is the command used erroneously on an odd page.}

\addlines

\lipsum[16-20]

\end{document}
  • It should be clarified that rather than a warning, it is error message that only appear in the second compilation. – Fran Aug 15 '15 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.