Repository navigation
\parshape is a primitive, so a document's own line widths reach the breaker - #798
Merged
Merged
Conversation
…reaker
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]>
…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 20, 2026
… does (#587) (#861) \list{label}{settings} discarded its second argument, which is where every \list-based environment of article.cls states its margins. Measured against tectonic on testdata/parity/listmargin.tex (quote, a two-paragraph quotation, verse, a wrapping description, and the text around them): tectonic main quote, every line 158.67-452.57 133.77-477.50 quotation, 2nd paragraph 173.62 then 158.67 148.72 then 133.77 verse one line per \\ both lines merged description bold label, 0; regular, 0; text hangs 24.91 no hang After: every line's x0, x1 and baseline within 0.03bp of the reference. #646 did the \list half of this in October and was held on the corpus; main has since gained its own \parshape primitive (#798), so this ports the rest onto it and re-measures rather than re-deriving. From the source, each piece: - \list is ltlists.dtx:552-573 in its own order (per-depth defaults, then the settings argument, then \parshape \@ne \@totalleftmargin \linewidth), with \@listdepth, \@totalleftmargin, \@mklab, \@setpar. - \par is {\@@Par} inside a list, written as the two \defs \@setpar produces: through \@setpar the non-\long argument {\@@Par} is abandoned by this engine's inverted runaway rule (#859, fix held). - \parshape is GROUP-SCOPED now (eq_define, tex.web:4754), and the end-of-paragraph reset goes through the same setter. Inside a list \par is {\@@Par} (ltlists.dtx:617-625): the reset happens in that group and is undone, which is how a list's second paragraph keeps its shape. paragraph.go recorded the plain-field version as a known divergence. - \linewidth is its own register (latex.ltx:11414). \list decrements it by both margins; through \let\linewidth\hsize that shrank \hsize. - The item lays its label out as \@item does (ltlists.dtx:940-1052): the label waits in \@labels for \everypar, which takes the indent box back with \lastbox (#848). Starting the paragraph at \item instead typeset the space after "\item\relax" and put every first line one stretched space (4.6-7.9bp) right of the reference's. First item cancels \parskip, later ones add \itemsep only (:950-961). - \endtrivlist ends the paragraph BEFORE its \endgroup, or the last paragraph is broken after the shape is gone. - \@centercr (ltmiscen.dtx:1155-1187), which verse's \\ is. - An unbraced \hspace / \setlength argument is that one token: article.cls's \descriptionlabel writes \hspace\labelsep, and the discard left \labelsep to run as an assignment — every description label 4.98bp (= \labelsep) left of the margin. TestSetLengthUnbracedValue pinned the discard as 0pt; tex.web:9043-9047 says the recovery assumes pt, so 2pt, which is what tectonic's "Illegal unit of measure (pt inserted)" is. And thebibliography, which is a \list too (article.cls:568-575): - \usecounter is ltlists.dtx:1083 (it was a no-op), and inside \list an \item with no [label] steps \@listctr through \refstepcounter (ltlists.dtx:1024-1032). - \bibitem inside a \list IS an \item (ltbibl.dtx:154-177); our class-less thebibliography, not a \list, keeps the old path. Against tectonic on testdata/parity/biblist.tex: labels were hung 20bp into the margin, continuations at 0, entries 11.96bp apart instead of 19.93 (\itemsep missing), the first line broke a word early. Now exact. - Our \@trivlist empties \@itemLabel (LaTeX's \trivlist does, not its \@trivlist), so \list sets it again after: without it every entry lost its [N]. - Unbraced arguments, as the kernel writes them: \setcounter{#1}\z@ (readBraceInt) and \refstepcounter\@listctr (readCounterNameArg). - Without natbib, \bibitem[label]{key} prints the label as the marker and the \cite text, and the plain entry is [1] — measured in tectonic, both configurations. TestBibitemLabelIsNotTypeset and TestBibliographyNatbibDoiGroupBalance had pinned natbib's numbering on documents that load no natbib; they now pin both configurations against the reference. 2203.15077 (revtex, natbib) is unchanged. ⚠ \bibitem's trailing \ignorespaces survives its mutation: the item stays in vertical mode until text starts, where TeX drops the space anyway. It is kept as ltbibl.dtx:177 has it. Tests: TestParityListMarginsMatchTheReference (every line's start), TestParityListSpacingMatchesTheReference (every baseline gap), TestParityBibliographyMatchesTheReference, TestLinewidthIsItsOwnRegister, TestSetcounterUnbracedValueIsOneToken. The parity helper now finds the first glyph inside a leading label box (it summed the box's whole width). Break-checked with mutate, each removed alone: the \parshape line, the {\@@Par}, \@centercr, the first item's -\parskip, the \lastbox, \list's \makelabel, \par-before-\endgroup, the unbraced argument — 8 of 8 caught. Co-authored-by: Claude Opus 5.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.
tex.web:23275-23286is the whole of the\parshapescanner:scan_optional_equals,scan_int, then n pairs of (indent, width) read as normal dimens. The engine had no\parshapeat all, so a document asking for its own per-line measure was silently set on the uniform one.This is item B3b of the paragraph-shape plan, and it is the last of the four shape parameters:
\hangindent/\hangafterlanded in #795, the one-paragraph reset in #796. Refs #795, #796 — both already merged, named here for the sequence and neither reopened nor altered by this change.Measured
On a 120pt measure with
\parindent=0pt, the same prose:ofeverypaper,andamea-\parshape=2 0pt 120pt 0pt 60ptofeverypaper,The words move, which is the observable that shows the shape reaching the line breaker rather than only the placement. Line 1 keeps the full measure and is byte-identical on both sides; every later line gets 60pt, because the last pair repeats (
:16680-16681) — which is why two pairs are a complete answer for a seven-line paragraph.⚠ The box width is the wrong observable for any of this, and the witness says so in a comment: a positive indent keeps the box at the full measure with a rigid kern inside it, so every box is
hsizewide either way. An earlier afternoon went into that.Two rules a mutation settled, rather than my reading of the source
\parshapewins over\hangindent.:16706testspar_shape_ptrfirst and consultshang_indentonly in theelsebranch, so a document setting both gets the shape and\hangindentis never read. Reading\hangindentfirst inparagraphShapemakes the precedence test, and only that test, fail —with both set the paragraph does not match the \parshape alone— with the other three still green. The test carries a control that the two parameters actually differ, or it would pass whatever order the engine read them in.n<=0early return is a panic guard, not an over-read guard. Removing it leaves\parshape=0unharmed — the pair loop is bounded by n and runs zero times either way — while\parshape=-1panics inmake([]Shape, 0, n)on a negative capacity, from a plain integer a document may write. 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 and names the claim it retracts.Caveat, stated in the code
parShapeis not on the save stack, so a shape set inside a group outlives the group.normalParagraphclears it at every\par(:20756-20761), which is the behaviour a document actually depends on; the grouping gap is real and narrower, and the code says so rather than implying full fidelity.The corpus run, and why it proves nothing on its own
⚠ That is the predicted result, not evidence of correctness.
gotex-paramcensusover the same 154 papers (679.texfiles, control\documentclassfound in 154) counts\parshapein 0 of them — so a measurement that moved anything would have meant a bug, and this A/B is a no-regression check and nothing more. It is\looseness's situation, and\hangindent's was barely different at 3 of 154.The witnesses that actually hold this change are the four unit tests, and the mutations above are what give them their teeth.
🤖 Generated with Claude Code