Skip to content

take linebreak v1.12.0, and \looseness with it - #825

Merged
tannevaled merged 1 commit into
mainfrom
take-linebreak-1-12-0
Nov 18, 2026
Merged

tannevaled merged 1 commit into
mainfrom
take-linebreak-1-12-0

Conversation

@tannevaled

@tannevaled tannevaled commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

⚠ Rewritten at 20:40. The first version of this body withheld the
\looseness wiring and offered an eighteen-row table as evidence that the
parameter could not reach the breaker. The table was measured on the wrong
glue.
The wiring is here, measured, with the correction kept in view below.

v1.10.0 → v1.12.0, plus one line of engine:

go-typeset/linebreak#21 a break discards the whole run of discardables, not one glue
go-typeset/linebreak#22 \looseness: the state is (position, line, fitness) — tex.web:16107-16114, :16716, :17197-17237
paragraph.go Looseness: e.namedInt("looseness")

\looseness, measured

lines
\looseness 0 3
\looseness 1 4

Twelve 10pt words on a 50pt measure, glue 4pt plus 8 minus 2: four to the line at
52pt shrinking, three at 38pt stretching — both decent, which is what gives the
choice something to choose between. The register was declared in texparams.go
and read by nothing (#754 item C, go-typeset/linebreak#12 item 7), so a document
that set it was obeyed in silence.

Three rows: the move, the control (\looseness=0 is the old behaviour
exactly), and an unreachable \looseness=5 that must still set the paragraph —
tex.web:17203 keeps what the final pass reached.

⛔ The fixture uses \hskip, not \spaceskip, and that cost an hour

My first draft set \spaceskip=4pt plus 8pt minus 2pt and produced eighteen
rows in which \looseness changed nothing — 6 to 15 words across three measures,
flat in both directions. I was one commit from publishing that as evidence that
the parameter does not reach the breaker.

It was the fixture. \spaceskip is a \newskip register in this engine and
not the base interword glue
— spacefactor.go:104-109 says so in as many
words. So every row was measured on spMock's own 3pt plus 1.5 space, where a
three-word line needs ratio 4.7 and no second ending survives \adjdemerits.
The parameter was reaching the breaker the whole time; there was nothing for it
to choose.

What separated it: driving the library's fixture from inside this engine's
binary (it moved, 3 → 4), then dumping the item stream the engine hands over and
reading w=3.00 y=1.50 z=1.00 where the source said 4/8/2.

The bump itself is inert on every witness I have

Seven documents compiled by a binary built from origin/main and one from this
branch, compared byte for byte: prose front sect floats (the four
that agree page-for-page with tectonic, #813), foot (\flushbottom),
foottwo ([twocolumn]), lccode (a 110pt \parbox hyphenating hard). All
seven identical; suite green on all 11 packages.

⚠ "Inert on seven witnesses" is not "inert on the corpus", and the corpus is
not on this machine. The discard-run change touches break_width only where a
break is followed by a run of discardables, which synthetic prose may never
build.

Refs #754, Refs #813,
Refs go-typeset/linebreak#21, Refs go-typeset/linebreak#22,
Refs go-typeset/linebreak#12.

🤖 Generated with Claude Code

v1.10.0 -> v1.12.0, which brings two library changes:

	linebreak #21  a break discards the whole RUN of discardables, not one glue
	linebreak #22  \looseness: the state is (position, line, fitness), not
	               (position, fitness) — tex.web:16107-16114, :16716, :17197-17237

and one line of engine: `Looseness: e.namedInt("looseness")`.

## \looseness, measured

	looseness 0   3 lines
	looseness 1   4 lines

A paragraph of twelve 10pt words on a 50pt measure, glue 4pt plus 8 minus 2:
four to the line at 52pt shrinking, three at 38pt stretching, both decent — which
is what gives the choice something to choose between. The register was declared
in texparams.go and read by nothing (#754 item C, linebreak#12 item 7), so a
document that set it was obeyed in silence.

Three rows: the move, the control (\looseness=0 is byte-for-byte the old
behaviour), and an unreachable \looseness=5 that must still set the paragraph —
tex.web:17203 keeps what the final pass reached.

## ⛔ AND THE FIXTURE IS \hskip, NOT \spaceskip, FOR A REASON WORTH THE NEXT HOUR

My first draft set `\spaceskip=4pt plus 8pt minus 2pt` and produced EIGHTEEN rows
in which \looseness changed nothing — 6 to 15 words across three measures, flat
in both directions. I was one commit from publishing that as evidence that the
parameter does not reach the breaker.

It was the fixture. \spaceskip is a \newskip register in this engine and NOT the
base interword glue; spacefactor.go:104-109 says so in as many words. So every
one of those rows was measured on spMock's own 3pt plus 1.5 space, where a
three-word line needs ratio 4.7 and no second ending survives \adjdemerits. The
parameter was reaching the breaker the whole time and there was nothing for it to
choose.

What separated it: driving the LIBRARY's fixture from inside this engine's binary
(it moved, 3 -> 4), then dumping the item stream the engine hands over and seeing
`w=3.00 y=1.50 z=1.00` where the source said 4/8/2.

## The bump itself is inert on every witness I have

Seven documents compiled by a binary built from origin/main and one from this
branch, compared BYTE FOR BYTE: prose, front, sect, floats (the four that agree
page-for-page with tectonic, #813), foot (\flushbottom), foottwo ([twocolumn]),
lccode (a 110pt \parbox hyphenating hard). All seven identical; suite green on
all 11 packages.

⚠ "Inert on seven witnesses" is not "inert on the corpus", and the corpus is not
on this machine. The discard-run change touches break_width only where a break is
followed by a RUN of discardables, which synthetic prose may never build.

Refs #754, Refs #813,
Refs go-typeset/linebreak#21, Refs go-typeset/linebreak#22.

Co-Authored-By: Claude Opus 5 <[email protected]>
@tannevaled
tannevaled force-pushed the take-linebreak-1-12-0 branch from 84b8698 to d0d8ed9 Compare November 17, 2026 19:40
@tannevaled tannevaled changed the title take go-typeset/linebreak v1.12.0 take linebreak v1.12.0, and \looseness with it Nov 17, 2026
@tannevaled
tannevaled merged commit 2ac3417 into main Nov 18, 2026
26 of 27 checks passed
@tannevaled
tannevaled deleted the take-linebreak-1-12-0 branch November 18, 2026 05:45
tannevaled added a commit that referenced this pull request Nov 18, 2026
Both were accept-and-ignore: declared as registers, read by nothing, so a
document that set either was handed the font's own space in silence.

## The rule, both branches

tex.web:20358-20370, app_space:

	if (space_factor>=2000)and(xspace_skip<>zero_glue) then
	  q:=new_param_glue(xspace_skip_code)
	else begin if space_skip<>zero_glue then main_p:=space_skip
	  else <Find the glue specification...>;
	  main_p:=new_spec(main_p);
	  <Modify the glue specification in main_p according to the space factor>;

and :20332-20338 for the ordinary space. They are NOT the same rule:

  * \xspaceskip is taken VERBATIM — whole, unscaled, no \fontdimen7 — and only
    when the factor is at least 2000;
  * \spaceskip replaces the FONT's space as the base and is then scaled by the
    factor exactly as the font's would have been, extra_space included (§1044
    adds extra_space(cur_font) whatever the base is).

⛔ ZERO IS "UNSET", NOT A WIDTH. :20328-20330 says TeX compares the parameter
against zero_glue by POINTER, so a \spaceskip of 0pt plus 0pt minus 0pt means
nobody set it and the font's space is used. nonZeroSkip asks that question and
not "width > 0", because `0pt plus 2pt` IS set — a space that can only grow. The
float skips had the same conflation in the other direction (#815).

## Why both halves at once

The note this replaces said half an implementation would be worse than none, and
it was right while only half could be written:

	⚠ Two parts of §1043 are NOT here … the \xspaceskip branch … and \spaceskip
	as the base glue … a document that sets them is unaffected today and would
	be wrongly affected by half an implementation.

Taking \spaceskip without the \xspaceskip branch would scale a parameter TeX uses
whole; taking \xspaceskip without the base would leave every ordinary space wrong.

## Tests

Seven rows. Five on the ordinary factor — the font's space as the CONTROL, the
document's glue, a zero \spaceskip falling back, `0pt plus 2pt` counting as set,
and \xspaceskip ignored below 2000 — and two at 2000, where the rules part: the
\xspaceskip taken whole (its 5pt of stretch stays 5, where scaling would double
it) against the control of the same factor with no \xspaceskip, which scales
\spaceskip's stretch to 8 and halves its shrink and adds \fontdimen7.

⭐ ATTRIBUTED: with the \spaceskip branch disabled, four rows go red and the two
CONTROL rows stay green. A witness that fired on its own controls would be
measuring something else.

## What this cost before it existed

A line-breaking fixture that set \spaceskip=4pt plus 8pt minus 2pt was handed the
mock font's 3pt plus 1.5, and eighteen configurations of it reported that
\looseness has no effect. It has one (#825). A silent parameter is worse than a
missing one: the fixture looks like it says something.

⚠ No corpus figure: gotex-paramcensus can say how many of the 154 measured papers
set either, and I have not run it.

Closes #826.

Co-authored-by: Claude Opus 5 <[email protected]>
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