Skip to content

\sloppy and \fussy do what latex.ltx says they do - #769

Merged
tannevaled merged 2 commits into
mainfrom
sloppy-fussy
Nov 14, 2026
Merged

tannevaled merged 2 commits into
mainfrom
sloppy-fussy

Conversation

@tannevaled

@tannevaled tannevaled commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

\sloppy and \fussy do what latex.ltx says they do

Both were \def\sloppy{} / \def\fussy{} — empty. latex.ltx:13367-13378 is the
whole of them:

\sloppy  \tolerance 9999  \emergencystretch 3em  \hfuzz .5\p@  \vfuzz\hfuzz
\fussy   \emergencystretch \z@  \tolerance 200   \hfuzz .1\p@  \vfuzz\hfuzz

⛔ \sloppy IS IN 775 OF THE 2935 CORPUS PAPERS — 26.4%, measured with TeX
comments stripped. A quarter of the corpus asked the line breaker to loosen and
this engine answered by doing nothing.

That census is also why this is the change being made rather than the
hyphenation exception list, which was next on a list I had ordered by how
clearly wrong each item looked:

\raggedright        871   29.7%
\sloppy             775   26.4%
\emergencystretch   301   10.3%
\hyphenation        170    5.8%
\uchyph               9    0.3%

\tolerance is the one this engine acts on (paragraph.go:195 reads it through
namedInt), so this takes effect. \emergencystretch, \hfuzz and \vfuzz are
accept-and-ignore parameters — the same as they already are when a document
assigns them directly — and are set so the definitions stay honest for a
document that reads them back.

⚠ \sloppy'S EFFECT IS CONDITIONAL, which is pinned by a test so a future reader
does not take a no-change for a broken command. Measured against tectonic
0.17.0: the same paragraph at \hsize=100pt comes out IDENTICAL under \fussy and
\sloppy, because it already fits within \tolerance=200. The two part only when
the paragraph genuinely fails at 200 — at \hsize=45pt the reference goes from
5 lines to 8.

The tolerance test asserts the STARTING value first, because \fussy's value and
the default are both 200 and a \fussy that did nothing would otherwise look
like one that worked. It also pins that the assignment is group-scoped: a
document that loosens one paragraph has not loosened the rest.

⚠⚠ THE CORPUS A/B IS OWED AND HAS NOT RUN. This changes paragraph breaking for
a quarter of the corpus and the honest measurement is a before/after against
the reference, not a witness. It has not run because the machine's 1-minute
load average is 73 — page counts would be exact under load, but 120 compiles
now would starve the ~27 other sessions sharing this host for hours. Deferred
on purpose and said out loud; this should not merge until it has run.

⚠ AND A LARGER DIVERGENCE SITS BESIDE THIS ONE. Our DEFAULT breaking is already
about as loose as the reference's \sloppy — 5 lines against our 8 on that 45pt
witness, with the font and the measure controlled. That is #768 and is not
addressed here; it is the opposite of the long-standing reading in #381/#449
that our lines hold MORE than the reference's.

Refs #768, #381, #449, #780, #781.

(#768's finding (2) is fixed by #780/#781, which is what unblocked this; its
finding (1) is what this PR implements. #381 and #449 stay open on purpose —
they are the line-capacity reading this PR's own text argues against, and it
does not settle them: the clean A/B after the rebase moves no page count at
all.)

⭐ Re-measured 2026-11-14 after #780/#781 — corpus-NEUTRAL, which removes the
reason this was held.
Rebased onto 3afebd8 so the only difference is
\sloppy/\fussy; 60 sampled at seed 1, load 5.1-5.7:

main with this
mean divergence 3.872 3.872 (−0.000)
mean line agreement 91.57% 91.58% (+0.01pt)
pages exactly the reference's 12/41 12/41 (±0)
Σ|page error| 126 126 (±0)

41 papers both sides, no status flips, no page count moved, five papers moving
by thousandths. The earlier A/B's −0.1 on one paper is gone: over a breaker that
is no longer too loose, this costs nothing. It does not help either.

⚠ And it is not the reference's \sloppy: on #768's witness ours now gives the
reference's \fussy line for line while the reference's \sloppy sets nine
underfull lines. Separate divergence, not claimed fixed here.

Co-Authored-By: Claude Opus 5 [email protected]

Both were `\def\sloppy{}` / `\def\fussy{}` — empty. latex.ltx:13367-13378 is the
whole of them:

	\sloppy  \tolerance 9999  \emergencystretch 3em  \hfuzz .5\p@  \vfuzz\hfuzz
	\fussy   \emergencystretch \z@  \tolerance 200   \hfuzz .1\p@  \vfuzz\hfuzz

⛔ \sloppy IS IN 775 OF THE 2935 CORPUS PAPERS — 26.4%, measured with TeX
comments stripped. A quarter of the corpus asked the line breaker to loosen and
this engine answered by doing nothing.

That census is also why this is the change being made rather than the
hyphenation exception list, which was next on a list I had ordered by how
clearly wrong each item looked:

	\raggedright        871   29.7%
	\sloppy             775   26.4%
	\emergencystretch   301   10.3%
	\hyphenation        170    5.8%
	\uchyph               9    0.3%

\tolerance is the one this engine acts on (paragraph.go:195 reads it through
namedInt), so this takes effect. \emergencystretch, \hfuzz and \vfuzz are
accept-and-ignore parameters — the same as they already are when a document
assigns them directly — and are set so the definitions stay honest for a
document that reads them back.

⚠ \sloppy'S EFFECT IS CONDITIONAL, which is pinned by a test so a future reader
does not take a no-change for a broken command. Measured against tectonic
0.17.0: the same paragraph at \hsize=100pt comes out IDENTICAL under \fussy and
\sloppy, because it already fits within \tolerance=200. The two part only when
the paragraph genuinely fails at 200 — at \hsize=45pt the reference goes from
5 lines to 8.

The tolerance test asserts the STARTING value first, because \fussy's value and
the default are both 200 and a \fussy that did nothing would otherwise look
like one that worked. It also pins that the assignment is group-scoped: a
document that loosens one paragraph has not loosened the rest.

⚠⚠ THE CORPUS A/B IS OWED AND HAS NOT RUN. This changes paragraph breaking for
a quarter of the corpus and the honest measurement is a before/after against
the reference, not a witness. It has not run because the machine's 1-minute
load average is 73 — page counts would be exact under load, but 120 compiles
now would starve the ~27 other sessions sharing this host for hours. Deferred
on purpose and said out loud; this should not merge until it has run.

⚠ AND A LARGER DIVERGENCE SITS BESIDE THIS ONE. Our DEFAULT breaking is already
about as loose as the reference's \sloppy — 5 lines against our 8 on that 45pt
witness, with the font and the measure controlled. That is #768 and is not
addressed here; it is the opposite of the long-standing reading in #381/#449
that our lines hold MORE than the reference's.

Refs #768.

Co-Authored-By: Claude Opus 5 <[email protected]>
@tannevaled

Copy link
Copy Markdown
Contributor Author

The corpus A/B this PR said it owed has now run, and it says do not merge this yet.

The measurement

60 papers sampled from a 200-paper pool, same seed both sides, gotex-refdiff against tectonic 0.17.0. Machine load 3-4 at the time, so it ran properly rather than under the 73 that made me defer it.

base rows=60 scored=37   head rows=60 scored=37
   2607.14223   94.5% -> 94.4%  (-0.1, revtex4-2)

moved=1 status_flips=0 only_base=0 only_head=0

One paper of 37 moved, and it moved down.

Two controls, because one number is not a result

Does the change act where it should? 2607.14223 uses \sloppy. So the one paper that moved is a paper this PR touches — the effect is attributable, not noise.

Was there enough exposure to conclude anything? 44 of the 200-paper pool use \sloppy — 22% — so roughly a dozen of the 60 sampled and perhaps eight of the 37 scored. The change had real opportunity and took it once.

Without the second control, "1 of 37 moved" could have meant "the only exposed paper moved", which would be a very different sentence.

What it means

The change is faithful — it is what latex.ltx:13367-13378 says — and on this sample it is not an improvement. That is consistent with two things already measured:

  1. \sloppy's effect is conditional. A paragraph that already fits within \tolerance=200 is set identically either way, which the reference confirms at \hsize=100pt. Most body paragraphs at a normal measure are in that case.
  2. \sloppy is a no-op, and we refuse the overfull lines the reference accepts #768: our default breaking is already about as loose as the reference's \sloppy — 5 lines against our 8 on a 45pt witness, with the face, the space and the tolerance all verified identical. Raising our tolerance from 200 to 9999 asks for more of what we already do too much of, so where it acts it can only move further from the reference.

So this is a correct change whose benefit is dominated by #768, and merging it now buys a measured −0.1% on one paper and nothing anywhere else.

What I am doing with it

Leaving it a draft. It should be re-measured after #768, where the same change over a breaker that is no longer too loose has a reason to help. The code and the tests are ready; it is the ordering that is wrong, not the work.

⚠ Not claimed: that it would help after #768. That is a hypothesis with a clear test, and the test is this same A/B run again.

🤖 Generated with Claude Code

@tannevaled

Copy link
Copy Markdown
Contributor Author

Re-measured against the new main, as this PR said to. It rebases clean, the suite is green, and the witness moved — but not to where I expected, and the corpus A/B is still owed.

#768's finding (2) is fixed (#780, main green at 11de0a1): the wide-open maxBadRatio pass is gone, so the reasoning that held this PR — "raising the tolerance asks for more of what we already do too much of" — no longer applies. This commit cherry-picks onto 11de0a1 with no conflict and go test ./... is green.

The witness, all four paragraphs

Same file, \hsize=45pt, the two paragraphs of #768's witness:

lines last two lines
reference \fussy 5 whelm ev- / ery paragraph.
reference \sloppy 9 every / para- / graph.
here \fussy 5 whelm every / paragraph.
here \sloppy, with this PR 5 whelm ev- / ery paragraph.

⭐ Our \sloppy is now the reference's \fussy, line for line — all five lines, x1 within 0.3pt. That is closer to the reference's \fussy than our own \fussy is: ours declines the ev-ery break at \tolerance=200 and takes it at 9999.

⛔ And we do not reproduce the reference's \sloppy at all. It sets NINE lines there — incompre-/hensi-/bilities/over-/whelm/every/para-/graph., every one underfull at badness 10000 and all feasible at \tolerance=9999, which its log confirms. We set five. So \tolerance=9999 does not make our breaker behave as TeX's does at 9999; something else decides, and this witness cannot say what.

⚠ So the two commands do now part, which is what this PR said its own test pins and what it could not demonstrate before: our \fussy and \sloppy differ on this witness where they used to be identical.

What is still owed

The corpus A/B. Machine 1-minute load is 12.8 right now, and the rule here is not to measure above ~8 — counts would be exact but a timeout changing which papers get scored is exactly the failure that makes an A/B unreadable. Deferred on purpose, not forgotten; the branch is sloppy-remeasure and the binaries build.

⚠ Not claimed: that this now helps the corpus. The previous A/B found 1 paper of 37 moved and it moved DOWN (-0.1). That measurement was taken against a breaker that has since been rewritten, so it says nothing about this one either way.

🤖 Generated with Claude Code

@tannevaled

Copy link
Copy Markdown
Contributor Author

The A/B this PR owed has run, properly this time, and the hold reason is gone: \sloppy is now corpus-neutral.

This PR was held with: "a correct change whose benefit is dominated by #768 … It should be re-measured after #768, where the same change over a breaker that is no longer too loose has a reason to help." #768's finding (2) is fixed (#780, #781), so that is the measurement.

The run

gotex-refdiff -layout, 60 sampled at seed 1, between 3afebd8 (current main) and the same commit with this change rebased onto it — so the only difference measured is \sloppy and \fussy. Load 5.1–5.7, under the ~8 threshold.

main with this
mean divergence 3.872 3.872 −0.000
mean line agreement 91.57% 91.58% +0.01 pt
pages exactly the reference's 12/41 12/41 ±0
Σ|page error| 126 126 ±0

41 papers both sides, identical populations, no status flips, no page count moved. Five papers moved at all, every one of them by a thousandth of a divergence point:

2607.28068  0.498 → 0.480     2606.29103  0.605 → 0.603
2607.26288  5.994 → 5.993     2607.08901  1.783 → 1.783
2607.18490  8.033 → 8.036

Four improved, one worsened, all far inside the noise.

What that changes

The previous A/B — taken against the old breaker — found 1 paper of 37 moved and it moved down (−0.1). That regression is gone: over a breaker that is no longer too loose, \sloppy costs nothing. It also does not help, on this sample.

So the honest position is: a faithful port with no measured corpus effect, which is the shape that lands. latex.ltx:13367-13378 is three assignments and \tolerance is the one this engine acts on; \sloppy appears in 775 of 2935 corpus papers (26.4%), and today it is a no-op in all of them.

⚠ And it is not the reference's \sloppy. On #768's witness at \hsize=45pt our \sloppy now produces the reference's \fussy line for line (five lines, whelm ev- / ery paragraph., x1 within 0.3pt) while the reference's own \sloppy sets nine underfull lines there. \tolerance=9999 does not make this breaker behave as TeX's does at 9999. That is a separate divergence, unaffected by this PR and not claimed to be fixed by it — what this PR does is stop the command being silent.

⚠ Not claimed: that \sloppy helps anywhere. Neutral is what was measured.

Marking ready on that basis.

🤖 Generated with Claude Code

@tannevaled
tannevaled marked this pull request as ready for review November 14, 2026 22:26
@tannevaled
tannevaled merged commit 676a9ea into main Nov 14, 2026
18 checks passed
@tannevaled
tannevaled deleted the sloppy-fussy branch November 14, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant