this post was submitted on 07 Jul 2023
2 points (100.0% liked)

TeX typesetting

106 readers
1 users here now

A place to share ideas, resources, tips, and hacks for Donald Knuths typesetting software TeX. All variants and formats like OpTeX, LaTeX and ConTeXt are welcome.

Tagging your post with [] is optional, but can help others to know if it uses or pertains to a certain format/engine/system.

Rules: Posts and comments should be civil and somehow related to *TeX and/or typesetting in general.

founded 1 year ago
MODERATORS
 

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
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 9 months ago

I’m not sure what the word “spread” means here. Seems to have a specific meaning.

I use the KOMA packages. So I tweak the DIV parameter as a final step in my doc creation. I start with trying DIV=8 and DIV=80 to see how many pages it works out to at both extremes. Then I play with numbers to ideally ensure the text reaches the bottom of an even numbered page (assuming I will print on both sides). It would be useful if a LaTeX tool could optimize the DIV for me. But at least I can tune things to give the biggest margins for a fixed number of full pages.

If DIV=14 produces a widow, then I’ll try DIV=15 but if 15 has a dramatic effect and wastes ½ a page, then I will go back to 14 and try to look for a place where text can be shortened to remove a line. I don’t understand that code but I might try increasing \widowpenalty if shortening text is difficult.