Repository navigation
a paragraph is broken on its own shape, so \hangindent is honoured - #795
Merged
Merged
Conversation
tex.web §847-850 recomputes line_width per line from hang_indent and hang_after.
The width is an input to the badness of every candidate break, so a shape is a
line-breaking parameter and not a placement one: a paragraph asking for
\hangindent is not the uniform paragraph moved over, it BREAKS somewhere else.
go-typeset/linebreak v1.10.0 grew the Measure that expresses it. paragraphShape
builds HangIndent from the register the engine already cached, breakSegment
passes it to all three passes, and each line is packed to its own width with a
rigid kern of its margin in front.
⛔ BOTH HALVES OF THE PLACEMENT ARE NEEDED, and a negative \hangindent is why:
there the margin is ZERO and the line is still shorter by |indent|, so a kern
alone would leave the target at the full measure and the rightskip glue would
stretch the text back across it. Reducing the target leaves the slack as empty
page, which is what indenting from the right means.
The witness, on a 120pt measure with \hangindent=24pt \hangafter=1 — note that
line 1 is untouched and the hyphenation CHANGES, because the narrower lines no
longer need it:
uniform "of every paper, and a mea-" "sure that is wrong by a cen-"
hung "of every paper, and a" "measure that is wrong"
And the dropped-shape census is gone with the drop. It reported every non-zero
\hangindent under the rule that a feature silently dropped is worse than one
refused; now that the engine honours the parameter, that report would be a false
statement about our own behaviour. hangIndentReg stays and matters MORE: it fed
a census, and now it feeds the feature, so a stale value no longer means a
report that never fires but every hanging indent ignored again.
Co-Authored-By: Claude Opus 5 <[email protected]>
tannevaled
added a commit
that referenced
this pull request
Nov 15, 2026
tex.web:20756-20761, called from nine places including vmode+par_end — every
\par:
procedure normal_paragraph;
begin if looseness<>0 then eq_word_define(int_base+looseness_code,0);
if hang_indent<>0 then eq_word_define(dimen_base+hang_indent_code,0);
if hang_after<>1 then eq_word_define(int_base+hang_after_code,1);
if par_shape_ptr<>null then eq_define(par_shape_loc,shape_ref,null);
end;
This engine kept the shape for ever.
⛔⛔ AND THAT BECAME A DEFECT THE MOMENT THE PARAMETER STARTED WORKING. While
\hangindent was accept-and-ignore, never resetting it cost nothing and no test
could have noticed. #795 made it shape the line breaker; the same omission then
hung every FOLLOWING paragraph. Measured before this landed, the same second
paragraph in two documents differing only in what their FIRST paragraph asked:
after a hung first: "measure that is wrong" / "by a centimetre is wrong"
after a plain first: "sure that is wrong by a cen-" / "timetre is wrong on every"
and the three parameters read back unchanged after \par — \hangindent 1572864
sp, \hangafter 3, \looseness 2, where TeX gives 0, 1 and 0.
⚠ Most LaTeX survived it anyway: an assignment inside a group is restored by the
save stack, and \@hangfrom and friends are grouped. The top-level assignment is
the one that leaked.
It writes through setCount/setDimen rather than the register slices, so the reset
takes part in grouping exactly as eq_word_define does — a reset that escaped its
group would be a second bug of the same family.
\parshape is absent because this engine has no such primitive yet; its reset
belongs on the line below when it grows one.
Co-authored-by: Claude Opus 5 <[email protected]>
tannevaled
added a commit
that referenced
this pull request
Nov 16, 2026
…wrote down The README describes the line breaker and never mentioned \hangindent, \hangafter or \parshape, although #795 implemented the first two, #796 made them last one paragraph, and this branch adds the third. A reader of the README could not tell that a document's own per-line measure reaches the breaker at all. It now says so, with the three facts a reader would otherwise get wrong: - the parameters reach the BREAKER, not only the placement; - \parshape WINS over \hangindent (tex.web:16706 tests par_shape_ptr first and consults hang_indent only in the else branch); - and all of them last ONE paragraph (:20756-20761). And it states the corpus result as what it is: \parshape set by 0 of the 154 measured papers and \hangindent by 3, so the A/B's Σ|page deviation| 306 -> 306 with 0 papers moved is the PREDICTED result and a no-regression check, not a fidelity win. Anything else would have meant a bug. Co-Authored-By: Claude Opus 5 <[email protected]>
tannevaled
added a commit
that referenced
this pull request
Nov 16, 2026
…reaker (#798) * \parshape is a primitive, so a document's own line widths reach the breaker tex.web:23275-23286 is the whole of the scanner: scan_optional_equals, scan_int, then n pairs of (indent, width) read as normal dimens. The engine had no \parshape at all, so a document asking for its own per-line measure was silently set on the uniform one. MEASURED, on a 120pt measure with \parindent=0pt: uniform 5 lines "ofeverypaper,andamea-" ... \parshape=2 7 lines "ofeverypaper," "andameasure" ... 0pt 120pt 0pt 60pt The words move, which is the observable that shows the shape reaching the BREAKER rather than only the placement. Line 1 keeps the full measure and is identical on both sides; every later line gets 60pt, because the last pair repeats (:16680-16681). TWO RULES THAT A MUTATION SETTLED RATHER THAN MY READING: - \parshape WINS OVER \hangindent (:16706 tests par_shape_ptr first and consults hang_indent only in the else branch). Reading \hangindent first in paragraphShape makes the precedence test, and only that test, fail: "with both set the paragraph does not match the \parshape alone". - the n<=0 early return is a PANIC GUARD, not an over-read guard. Removing it leaves \parshape=0 unharmed -- the pair loop is bounded by n and runs zero times either way -- while \parshape=-1 panics in make([]Shape, 0, n) on a negative capacity. An earlier draft of the comment claimed the guard stopped the scanner eating the document's next two dimensions; it cannot, and the mutation said so. The comment now records what was measured. The shape lasts one paragraph: normal_paragraph clears par_shape_ptr (:20756-20761), with the caveat, stated in the code, that parShape is not on the save stack. Also: the box WIDTH is the wrong observable for any of this, and the witness says so -- a positive indent keeps the box at the full measure with a rigid kern inside it, so every box is hsize wide either way. The text per line is what moves. Plan #792, item B3b. Co-Authored-By: Claude Opus 5 <[email protected]> * README: the per-line measure, which three merged pull requests never wrote down The README describes the line breaker and never mentioned \hangindent, \hangafter or \parshape, although #795 implemented the first two, #796 made them last one paragraph, and this branch adds the third. A reader of the README could not tell that a document's own per-line measure reaches the breaker at all. It now says so, with the three facts a reader would otherwise get wrong: - the parameters reach the BREAKER, not only the placement; - \parshape WINS over \hangindent (tex.web:16706 tests par_shape_ptr first and consults hang_indent only in the else branch); - and all of them last ONE paragraph (:20756-20761). And it states the corpus result as what it is: \parshape set by 0 of the 154 measured papers and \hangindent by 3, so the A/B's Σ|page deviation| 306 -> 306 with 0 papers moved is the PREDICTED result and a no-regression check, not a fidelity win. Anything else would have meant a bug. Co-Authored-By: Claude Opus 5 <[email protected]> --------- Co-authored-by: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
\hangindentis honoured: the paragraph is broken on its own shape, not set on one measure and indented afterwards. The corpus A/B moves NOTHING — zero papers — which makes this safe to land and is also the weakest possible support for the hypothesis that this mechanism explains #381. Closes #757. Refs #792, #754, #381 — all three stay open.What TeX does, and what this engine did
tex.web§847-850 recomputesline_widthper line fromhang_indentandhang_after. The width is an input to the badness of every candidate break, so a shape is a line-breaking parameter and not a placement one.This engine declared
\hangindent, made it settable, read it back — and consulted it nowhere. It even cached which\dimenregister the name finally resolved to (engine.go, becauseclasskernel.gorebinds it aftertexparams.godeclares it) purely so it could report the drop.go-typeset/linebreakv1.10.0 grew theMeasurethat expresses a per-line width. So:paragraphShapebuildsHangIndent(lineWidth, indent, hangafter)from that register;breakSegmentpasses it to all three passes;⛔ Both halves of the placement are needed, and a negative
\hangindentis why. There the margin is zero and the line is still shorter by|indent|(:16729-16730) — it indents from the right. A kern alone would leave the pack target at the full measure and the\rightskipglue would stretch the text back across it, so the indent would vanish into the justification. Reducing the target instead leaves the slack as empty page, which is what indenting from the right means.The unit witness: the words move, and the hyphenation changes
120pt measure,
\hangindent=24pt \hangafter=1:Line 1 is untouched, which is
\hangafter=1. And the narrower lines no longer need the hyphens the uniform setting took — so this is the breaker changing its mind, not a paragraph being shifted.⚠ My first version of that test measured the wrong thing and I nearly reported the feature broken. It compared line-box WIDTHS, which are identical either way: a positive
\hangindentkeeps the box at the full measure with the kern inside it, because a line box here carries noshift_amount. A throwaway probe showed the register did hold 24pt at paragraph time. The right observable is the text per line.⚠ The corpus A/B: zero
154 of 154 scored, so nothing was decided by the clock.
This contradicted my own prediction.
amssubstrate.go's\@hangfromdoes\hangindent\wd\@tempboxa\noindent\box\@tempboxa, so I expected every\bibitemand every hanging heading in a real class to move. Two explanations fit the zero and I cannot separate them from here:\@hangfromonly ever shapes section headings, which run to one or two lines, and a hanging indent changes nothing until there are lines after the first;⭐ The measurement that separates them, and it is not in this PR: count the paragraphs broken with a non-
Uniformmeasure across the corpus, and how many of those have more than one line. Until that is run, neither explanation is established.⚠ What the zero does and does not license
And the dropped-shape census is gone with the drop
It reported every non-zero
\hangindent, under the rule that a feature silently dropped is worse than one refused — which was right while it was true. Now that the engine honours the parameter, that entry would be a false statement about our own behaviour, which is worse than either the drop or the silence.droppedshape_test.gois inverted accordingly, and its register-cache tests are kept and strengthened: that cache fed a report and now feeds the feature, so a stale value no longer means a census that never fires but every hanging indent silently ignored again.⭐ A repository gate caught a real mistake here:
TestDocCommentNamesItsOwnFunctiontold me, by name, that I had insertedparagraphShapebetweenbreakSegment's doc comment and its body.gofmt -l .prints nothing,go vet ./...clean,go test ./...green on all nine packages.⚠ Not claimed
\parshape. It is not a primitive in this engine at all, so a document writing it gets an undefined command rather than a silently dropped shape.linebreak'sParShapeis ready for it; adding the primitive is separate work.shift_amount; it is equivalent for the cases above, and I have not diffed a rendered line against the reference.\hangafterscanning. It was already an integer parameter with its own test, and this reads it throughnamedIntfor that reason.🤖 Generated with Claude Code