Skip Navigation

Search

Dealing with widows (and orphans if we want).

Orphans and widows. On this subject Tschichold wrote:

"Doubtless all textbooks of typesetting warn that the exit line of a paragraph at the head of a book page must be avoided at all cost. /.../ Is there really nothing we can tighten a little, or space out perhaps? Possibly we can save a line at the beginning of the chapter by moving the first paragraph up? The best method is to simply shorten the preceding page by a line."

Bringhurst wrote:

"Balance facing pages not by adding extra lead or puffing up the word space, but by exporting or importing single lines to and from the preceding or following spreads. The same technique is used to avoid widows, and to extend or shorten any chapters that would otherwise end with a meager few lines on the final page."

In TeX we can set \widowpenalty (and \clubpenalty) to 10000 and if we have vertically stretchable material on the page the type area will get it's height, but lines will not match across the spread. Without strechable material that page will be a line shorter but the spread will be unbalanced in height instead.

So if we want this hands-on method of dealing with widows, we need a macro to carefully extend or shorten pages, preferably without being too intrusive and spread out in the code.

Luckily, Petr Olsak has a macro like this for OpTeX: https://petr.olsak.net/optex/optex-tricks.html#widows

For my purposes, I like the page number to be at a set distance from the type area instead of a set distance from the page bottom, so I could remove some code, and ended up with this example for plain:

``` % For this example, the document normally has 5 lines per page \vsize=\topskip \advance\vsize by 4\baselineskip

% Backup original vsize \newdimen\originalvsize \originalvsize=\vsize

% Macro that defines another macro on the form \ap:<pageno>, % which expands to how many lines should be adjusted. % Example: \adjustpage{15}{+1} defines \ap:15 which expands to +1. \def\adjustpage#1#2{% \expandafter\xdef\csname ap:#1\endcsname{#2} \ifnum #1=1 \setvsize \fi }

% For use in the output routine \def\setvsize{% \global\vsize=\originalvsize \ifcsname ap:\the\pageno\endcsname \global\advance \vsize by \csname ap:\the\pageno\endcsname \baselineskip \fi }

% \setvsize needs to be expanded after page number has been incremented, but before the next typeset material. \output{\plainoutput \setvsize}

%%%%%%%%%%%%%%%%%%%

% No penalty since we're dealing with widows manually now \widowpenalty=0 \clubpenalty=0

% This adjusts the 2-3 spread to have one extra line on each page \adjustpage{2}{+1} \adjustpage{3}{+1}

% Test text, some paragraphs of Lorem ipsum \input lipsum

\bye ```

0

A Pragmatic Approach to Paragraphs, by Philip Taylor

What's your method for dealing with underfull/overfull \hboxes and unacceptable badness in general?

LaTeX has the \sloppy command which IIRC sets \tolerance to 9999, and \emergencystretch to a large value. But the default \tolerance is 200 (I think), which is a big difference. It's very "either/or" when maybe there's a more optimal way.

For my native language (swedish) I've found that many issues arise because TeX doesn't find all the possible hyphenation points, so I usually spend time adding words to the hyphenation list.

But still, in any longer text there's usually a couple of paragraphs that just won't set right, I'm curious about your tricks or methods for dealing with them.

0

Quantum spaces: Designing pages on grids

This is a rather interesting presentation by Jean-Luc Doumont about placing content on a grid, or a subset of the grid. He's kind of taking this idea to the extreme.

0

A macro to visualize boxes

There's this guy called Stephan V. Bechtolsheim who wrote a series of books on TeX called "TeX in Practice". He's really good at the finer details of, well, everything.

In one of the books, he makes a macro to visualize boxes. It's built up over many pages and chapters with lots of small macros as building blocks. Because he's reusing these macros in different places, it makes a lot of sense.

However, when I wanted to use the box visualizing macro, I found that I had to look up and copy a lot of code to make it work. This was no fun, so I re-wrote it in a "flatter" way where it's just regular plain old macros.

I ended up with this:

``` \newdimen\linethickness \linethickness=0.4pt

\def\boxlines #1{% \hbox{% % Save original (argument) box \setbox0 = #1% % Place bullet at baseline and vertical align of the box \setbox1 = \hbox{\hskip -2.5pt \lower 2.5pt \hbox{$\circ$}}% \ht1=0pt \dp1=0pt \wd1=0pt \box1 % Place a dashed line at baseline \setbox2 = \hbox to \wd0{% \xleaders\hbox to 4pt{% \hskip 1pt \vrule depth 0.5\linethickness height 0.5\linethickness width 2pt \hfil }% \hfil }% \ht2=0pt \dp2=0pt \wd2=0pt \box2 % Place frame \setbox 3 = \hbox{% \hskip -0.5\linethickness \vrule width \linethickness height \ht0 depth \dp0% \hskip \wd0% \hskip -\linethickness \vrule width \linethickness height \ht0 depth \dp0% \hskip -\wd0% \hskip -\linethickness \dimen0 = \wd0% \advance\dimen0 by \linethickness \dimen2 = \ht0% \advance\dimen2 by 0.5\linethickness \dimen4 = \ht0% \advance\dimen4 by -0.5\linethickness \dimen4 = -\dimen4 \vrule width \dimen0 height \dimen2 depth \dimen4 \hskip -\dimen0 \dimen2 = \dp0% \advance\dimen2 by -0.5\linethickness \dimen2 = -\dimen2 \dimen4 = \dp0% \advance\dimen4 by 0.5\linethickness \vrule width \dimen0 height \dimen2 depth \dimen4 }% \ht3=0pt \dp3=0pt \wd3=0pt \box3 % Place original argument box \box0 }% } ```

The macro takes a box as an argument, for example \boxlines{\box0}

It puts lines around the box, and marks out the baseline and the horizontal alignment. The neat thing is that the lines are made so that they don't interfere with the typesetting at all. Everything is placed as it would be without the lines.

If you have something that looks misaligned or strange, like these words:

!

it can help to visualize the boxes:

!

0