Typesetting demerit 2026-11-05
A typesetting demerit is a contribution to the paragraph cost minimized by the Knuth-Plass line-breaking algorithm. It combines spacing quality with break preferences and, when applicable, costs involving neighbouring lines. Thus typesetting badness is one input to the cost rather than the entire objective.[ref]
Consider the ordinary finite-penalty case in TeX, away from its integer saturation and recovery cases. Let be the TeX line penalty, the typesetting badness and the typesetting penalty, with and . The base contribution is
Charges for incompatible line-breaking fitness classes or consecutive hyphenated lines can then be added.
For an illustrative choice , and , the base is . Changing only to gives . If an adjacency charge of 100 applies, those become 1025 and 975. These are chosen example parameters, not asserted defaults.
Dynamic programming compares accumulated costs while retaining the dynamic programming state needed by future charges. The lowest-cost break considered alone need not produce the lowest-cost complete text paragraph.
Typesetting glue 2026-11-05
Typesetting glue represents adjustable space between pieces of typeset material. In a finite, single-order model, describe a glue item by a nominal width , stretch coefficient and shrink coefficient . A shared line adjustment ratio gives
Thus a negative reduces the gap. The coefficients describe relative flexibility; they need not be identical for all spaces. This model is a useful part of text justification.[ref]
For example, two nominal gaps of width 3 with stretch coefficients 1 and 3 become and when . Their total extra width is 2. With shrink coefficients 1 and 1, makes both gaps width 2. The same natural line can therefore reach different targets by using the appropriate coefficients.
Figure 1.
Proportional stretching and shrinking of typesetting glue
. Original finite-glue example: boxes of widths 8,6,10; two gaps with nominal width 3, stretch coefficients 1 and 3, and shrink coefficients 1 each. The generator computes the adjustment ratios and resulting widths. Details.
TeX also distinguishes typesetting glue orders, so the finite model above does not describe every glue setting. In a horizontal line, typesetting glue changes gaps rather than stretching the outlines of the glyphs.
Typesetting glue order 2026-11-05
A typesetting glue order assigns a priority to stretch or shrink in TeX. The orders are normal finite flexibility, fil, fill and filll, in increasing priority. With nonnegative coefficients, the highest present order absorbs the adjustment; lower-order flexibility is left unused.[ref]
For example, suppose a line has natural width 22 and must reach width 34. Two zero-width glue items have stretch coefficients 1fil and 2fil. Their added widths are
A finite-order glue item in the same line keeps its nominal width during this adjustment. The symbols define priorities for distributing a finite width difference. Within the selected order, the coefficients still determine proportional sharing.
The simple finite model in typesetting glue uses only the normal order. Higher orders make it possible to place flexible space at selected locations, such as before or after a line's content, without requiring the ordinary word spacing to absorb that particular adjustment.
Typesetting penalty 2026-11-05
A typesetting penalty expresses how desirable a candidate break is. In the Knuth-Plass line-breaking algorithm's paragraph representation, a penalty item can also have a width that is included only if that break is taken. This lets the model account for a hyphen introduced by hyphenation without printing it in the unbroken word.[ref]
For example, suppose the material before an optional break uses 29 units and taking the break introduces a hyphen of width 2. At a typesetting line width of 30, the broken line needs units before any permitted adjustment of typesetting glue. Testing only the pre-hyphen width would wrongly declare it a fit. A finite penalty can discourage a break while still leaving it available when other choices are worse.
In TeX, values prohibit a penalty break and force it. Intermediate positive values discourage and negative values encourage it. These are control conventions of the implementation, not physical lengths.[ref]
The penalty value is an input to the typesetting demerit calculation. It is not the entire paragraph cost: typesetting badness, line-breaking fitness classes and consecutive hyphenated breaks can contribute too. Comparing two penalties alone therefore cannot choose the best text paragraph layout.
Victor Eijkhout 2026-11-05
Victor Eijkhout is a computing researcher and author of TeX by Topic by Victor Eijkhout, a technical reference explaining how TeX processes input, expands macros and builds typeset material. Its subject-based organization makes the distinction between TeX tokens, TeX expansion and later layout operations explicit.[ref]
A small example illustrates the kind of mechanism such a reference explains. Define a TeX macro with \def\double#1{#1#1}. The call \double{ab} substitutes the argument's two letter tokens twice, producing the expanded letter-token sequence abab. In contrast, \double ab takes only the next unbraced letter token as its argument; the remaining b follows the replacement, giving aab. These are own illustrative calls under ordinary tokenization, not quotations from the book.[ref]
The example shows why reading source as raw character substitution can be misleading. Argument boundaries and tokenization are part of the computation; the eventual visual layout is a later concern. That separation connects a practical typesetting problem with more general ideas about programming language processing.
His institutional profile also identifies work in numerical linear algebra, scientific computing and parallel computing, and links his computing textbooks. These are professional contributions beyond the TeX reference, rather than evidence inferred from a similarly named person.[ref]
Figure 1.
Portrait of Victor Eijkhout
. Portrait linked from the institutional profile at the Texas Advanced Computing Center. Source.