# Prevent LaTeX from making pages longer or shorter (i.e. changing the text height)

When I try to prevent widows/orphans by increasing \widowpenaltyand clubpenalty, LaTeX usually decides to either make the page one line shorter (to prevent an orphan) or one line longer (to prevent a widow on the next page). How do I make LaTeX attempt to minimize widows/orphans, but without using this method? I have a vertical rubber length skip every few paragraphs and I was hoping LaTeX would use that instead.

Follow-up question: Making the page one line shorter or longer is permissible in a book if the facing page is shortened/lengthened by the same number of lines. Is there a way to let LaTeX make a page one line shorter or longer as long as the two facing page of a spread are always the same length?

Here's my MWE. Notice that on same pages there's a widow/orphan and the facing page has a different length. For example, on pages 8-9 we get two pages of unequal length for no apparent reason!

\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}{
{}{}{\textsc{\thesection{} \sectiontitle{}}}
\setfoot[\usepage][][]
{}{}{\usepage}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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

\maketitle
\cleardoublepage
\pagestyle{myfancy}

\chapter*{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}

• see for example tex.stackexchange.com/questions/248417/… – David Carlisle Aug 9 '15 at 20:15
• I just found out that the textheight and baselineskip were incompatible (textheight was not equal to a whole number og baselineskips + topskip). Adding the heightrounded option to geometry fixed this. An answer to the follow-up question (if an answer exists) is still appreciated. – Pétur Aug 10 '15 at 15:19

I found out that the reason LaTeX didn't have consistent textheight (one \baselineskip less on one page, one \baselineskip more on another) was that the \textheight and \baselineskip set by

\usepackage[textwidth=112mm,textheight=190mm, paperwidth=153mm, paperheight=230mm]{geometry}


were incompatible. It is my understanding that if \textheight is not equal to n times \baselineskip plus \topskip for some integer n, then an underfull vbox is unavoidable in some cases, prompting LaTeX to break pages in weird places.

Thankfully, there's an easy fix. Just use the option heightrounded:

\usepackage[textwidth=112mm,textheight=190mm, paperwidth=153mm, paperheight=230mm heightrounded]{geometry}


It will round \textheight to a better value. You can also set it manually.

With this setting and moderate values of \widowpenalty and \clubpenalty (I'm using 500), you shouldn't run into this problem. If you want to prevent a widow or orphan by increasing/decreasing the text height on both pages of a spread, you can add \enlargethispage{\baselineskip} (or -\baselineskip) on both sides of the page break. I'm not aware of a better solution yet.