Repository navigation
\tolerance and \hyphenpenalty are TeX's, not a fresh register's - #380
Conversation
They govern how the line breaker chooses — how bad a line may be before the
paragraph is rebroken with hyphenation, and what a hyphen costs when it is.
TeX's values are 200 and 50 (tex.web §240); LaTeX leaves both alone.
The kernel here declared them as fresh \newcount registers, so they read
\the\tolerance 10000 (tectonic: 200)
\the\hyphenpenalty 0 (tectonic: 50)
and SHADOWED the engine's own correct defaults — texparams.go has tolerance 200,
engine.go sets hyphenpenalty 50, and breakSegment reads the REGISTER. At 10000 no
line is ever too loose or too tight to accept, so the breaker packs where TeX
would rebreak; at 0 a hyphen costs nothing, so it hyphenates where TeX would not.
Found while asking why our lines hold more characters than the reference's with
the font and the measure both controlled — 69 against 66 on a real paper, of
which the interword space (#352) accounts for one.
MEASURED: Sigma 301 -> 301 over the 154-paper corpus, glyphs +23, nothing lost.
Free, and strictly more faithful. It does not close the 69/66 gap on its own:
our FIRST pass (at \pretolerance, unchanged at 100) still succeeds where TeX's
fails and goes on to hyphenate, which is the next thing to look at.
Co-Authored-By: Claude Opus 5 <[email protected]>
Crossing the kernel's \newcount/\newdimen/\newskip declarations against the
engine's own parameter table finds SIXTEEN names declared in both places. A
\newcount starts at zero, so each of those reads zero rather than TeX's value —
but only the ones the engine READS matter, and there are three:
tolerance 10000 (a stated value, not zero) fixed above
hyphenpenalty 0 fixed above
finalhyphendemerits 0 TeX: 5000 here
breakSegment reads all three. At zero, a hyphen on the second-to-last line of a
paragraph costs nothing extra, where TeX charges 5000 demerits for it.
The other thirteen — clubpenalty, widowpenalty, brokenpenalty, interlinepenalty,
predisplaypenalty, postdisplaypenalty, hangafter, spacefactor, hbadness,
vbadness, day, month, year — are read NOWHERE today, so the shadowing costs
nothing yet. It is worth knowing that \clubpenalty and \widowpenalty read 0: when
the page builder learns to honour them, the register has to be given TeX's 150
first or the feature will look implemented and do nothing.
MEASURED: Sigma 301 -> 301, glyphs +23, nothing lost — same as before this
commit, so the third parameter changes no page in the corpus either.
Co-Authored-By: Claude Opus 5 <[email protected]>
|
Extended after an audit of the whole shadow list. Crossing the kernel's
The other thirteen — Σ unchanged at 301, glyphs +23, nothing lost. |
Fixing the register's default (above) made \the\hyphenpenalty read 50, but an
ASSIGNMENT still went nowhere: \hyphenpenalty resolves to a \newcount here, so a
document writing \hyphenpenalty=10000 wrote the register while hyphenateList kept
reading the Go field. Two of the corpus's papers ask for exactly that —
2205.03780, 2209.13121: \hyphenpenalty=10000 \tolerance=1
and both were hyphenated anyway. The discretionary now takes the register when
one is defined, so the suppression works:
2205.03780 before 34 pages, 181 hyphenated line ends
after 34 pages, 0
Same 34 pages, same last words. The glyph delta the A/B tool reports for it,
-181, is exactly the hyphens it no longer sets — checked rather than assumed,
after mistaking a redistribution for a loss earlier today.
MEASURED: Sigma 301 -> 300 (-1) over the corpus, and the two papers above are the
only ones that move.
It does NOT explain #381. With hyphenation suppressed on BOTH sides, our breaks
still differ from tectonic's on the same paragraph in the same face at the same
measure — so what remains there is the breaker's choice, not the availability of
hyphens.
Co-Authored-By: Claude Opus 5 <[email protected]>
They govern how the line breaker chooses: how bad a line may be before the paragraph is rebroken with hyphenation, and what a hyphen costs when it is. TeX's values are 200 and 50 (tex.web §240); LaTeX leaves both alone.
The kernel declared them as fresh
\newcountregisters:\the\tolerance\the\hyphenpenaltyand those registers shadow the engine's own correct defaults —
texparams.gohas tolerance 200,engine.gosetshyphenpenalty50, andbreakSegmentreads the register. At 10000 no line is ever too loose or too tight to accept, so the breaker packs where TeX would rebreak; at 0 a hyphen costs nothing, so it hyphenates where TeX would not.How it was found
By asking why our lines hold more characters than the reference's with the font and the measure both controlled: 69 against 66 on a real paper (
2403.10748, same 346pt measure, samelmroman10). The interword space (#352) accounts for one of the three; these two parameters were the next suspects.Measured
Σ 301 → 301 over the 154-paper corpus, glyphs +23, nothing lost. Free, and strictly more faithful.
It does not close the 69/66 gap on its own, and the PR does not claim it does: our first pass — at
\pretolerance, unchanged at 100 — still succeeds where TeX's fails and goes on to hyphenate (bad-/hyphen-there,hy-here). That is the next thing to look at, and it is a question about the badness test, not about these two numbers.🤖 Generated with Claude Code