Repository navigation
a \hangindent the engine drops is now SAID, not swallowed (514 of 2935 papers ask for one) - #760
Merged
Merged
Conversation
\hangindent is declared (classkernel.go), listed among the dimension
parameters a document may set (texparams.go), assignable, and readable back
with \the -- and NOTHING EVER CONSULTS IT. A document asks for a hanging
indent, the assignment succeeds, and the paragraph is set on one measure
with no diagnostic of any kind.
HOW MUCH OF THE CORPUS ASKS FOR IT
papers listed 2935, read 2935, unreadable 0
papers that WRITE \hangindent = 514
papers that WRITE \parshape = 91
514 of 2935 -- 17.5%. TeX comments stripped, after a census I ran without
stripping them reported three papers where the true answer was one.
⚠ That is a STATIC count and an upper bound: a paper that writes
\hangindent inside a branch that never runs is counted and would not be
reported by the engine. What the engine actually reports needs a corpus
run, and this is what makes that run possible at all.
WHAT THIS CHANGES
One comparison on a path that was already happening. setDimen is the single
choke point for every write to a dimension register -- \hangindent=4em,
\setlength{\hangindent}{...}, \advance\hangindent all pass through it -- so
the drop is recorded there and reaches the skip census the engine already
reports at the end of every run.
Only a NON-ZERO value is a drop. \hangindent=0pt asks for no hanging
indent, which is exactly what this engine does; reporting it would be noise
on every document, since LaTeX's own \@endparenv and friends zero it
routinely.
⛔ THE CACHE IS MAINTAINED IN define, AND THE NATURAL PLACE WOULD BE WRONG
Caching the register at the end of loadTeXParams, beside \endlinechar and
\escapechar, is the obvious thing to do. classkernel.go runs AFTERWARDS and
declares \newdimen\hangindent, rebinding the name to a different register.
Measured, by building it the natural way and running the tests:
the engine watches dimen register 21 but \hangindent resolves to 59
-- and 104 once a document declares its own. The census would have reported
nothing, for every document, for ever, while looking perfectly alive. That
is the same load-order trap that took \prevdepth (#438) and \hangafter
(#759), silently, both times. define sees every binding including the ones
that come later.
The register index defaults to -1, NOT 0: register 0 is a real register
somebody else holds, and a zero default would report every assignment to it
as a dropped hanging indent.
⛔ A CORRECTION TO #757, WHICH ITS OWN TEXT GOT WRONG
#757 says "\parshape is the general case and has the same status". It does
not: git grep -n parshape -- '*.go' has ZERO hits. \hangindent is declared
and unread -- silent. \parshape is not defined at all, so it already goes
through the undefined-command path and already appears in the census. Those
91 papers were already visible; these 514 were not.
⚠ NOT CLAIMED: that a dropped indent costs any particular number of lines
or pages. The breaker cannot be told a per-line measure at all yet
(go-typeset/linebreak#11), so there is no second reading to compare
against. This says what was ASKED FOR and refused, not what it cost -- which
is the point: it took an audit to find this, and an audit is the most
expensive way to learn something the engine could have said on the first
document that asked.
Refs #757.
Co-Authored-By: Claude Opus 5 <[email protected]>
tannevaled
added a commit
that referenced
this pull request
Nov 13, 2026
…r destroyed (#771) Two things, and the first found the second within minutes. ⛔ THE ENGINE DETECTED OVERFULL LINES AND TOLD NOBODY hasBadLine decides which line-breaking pass to run and has done since line breaking was written. Nothing ever reached a caller, so a document whose text runs into the margin compiled in silence — the single most common thing a real TeX complains about, and the reason a reader opens the log at all. Same shape as the \hangindent defect of #760: a condition the engine detects, acts on, and keeps to itself. gotex: WARNING 1 overfull line(s) — text runs past the margin; the worst by 133.25pt Measured against tectonic 0.17.0 on a \texttt token at \hsize=40pt: reference Overfull \hbox (133.25pt too wide) here the worst by 133.25pt ⛔⛔ AND THE FIRST VERSION MISSED EXACTLY THAT CASE. It asked each Line for its Ratio and counted `Ratio < -1`. The ratio is the GLUE adjustment, and a line whose content is one unbreakable token has no shrinkable glue at all — no ratio to be past -1, so the count was zero while the line hung 133pt into the margin. The width is what a reader sees, so the width is what is measured. ⛔⛔ THEN IT FOUND A REGRESSION OF MINE, ON ITS FIRST REAL DOCUMENT An INDENTED paragraph at \hsize=45pt beginning with `Typographical`: 15pt of indent leave 30pt for a word needing 65, and since #766 a paragraph's first word is not hyphenated — which is right, tex.web §894/§896, and the reference does the same. But that removed the break this engine was relying on. No feasible set exists, breakSegment fails, and the fallback fired: lines = []Line{{Start: 0, End: len(list)}} // "last resort: one line, nothing lost" It lost the paragraph. 254.47pt past a 45pt margin, every word present and none of it readable. WHAT THE REFERENCE DOES THERE Typographical <- alone, OVERFULL, overhanging the margin incompre- hensibil- ities over- whelm ev- ery para- graph. It sets the unbreakable word as an overfull line and carries on. That is #768's mechanism from the other side: TeX leaves a line overfull and this breaker cannot produce one, so where TeX overhangs we had nothing to fall back to. greedyLines now breaks at the last legal point that fits and lets a run that cannot fit overhang alone — the same first line and the same first break as the reference, then a greedy approximation. It is a MITIGATION, not #768's fix: making the breaker itself able to return an overfull line lives partly in go-typeset/linebreak. ⚠ THREE DRAFTS OF greedyLines WERE WRONG, each caught by looking at the page 1. It advanced past the node at the breakpoint unconditionally. That is the space after a word and THE LETTER AFTER A DISCRETIONARY: the text came out as `incom / rehensibil / ties / helm / raph.`, losing the p, the i, the w and the g. Content destroyed is worse than the unreadable line. 2. When nothing fitted it cut at the character where the width ran out, putting `Typogr` and `aphical` on separate lines with no hyphen — a break TeX would never make, presented as if it were one. 3. Its break index pointed one PAST the break node, where paragraph.go:122 emits the hyphen only when `list[ln.End]` IS the discretionary. The breaks were in the right places with every hyphen missing. There is a test for each. Refs #766, #768. 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 declared (classkernel.go), listed among the dimension parameters a document may set (texparams.go), assignable, and readable back with\the— and nothing ever consults it. A document asks for a hanging indent, the assignment succeeds, and the paragraph is set on one measure with no diagnostic of any kind.How much of the corpus asks for it
514 of 2935 — 17.5%. TeX comments stripped, after a census I ran without stripping them reported three papers where the true answer was one.
⚠ That is a static count and an upper bound: a paper that writes
\hangindentinside a branch that never runs is counted here and would not be reported by the engine. What the engine actually reports needs a corpus run, and this PR is what makes that run possible at all.What this changes
One comparison on a path that was already happening.
setDimenis the single choke point for every write to a dimension register —\hangindent=4em,\setlength{\hangindent}{…},\advance\hangindentall pass through it — so the drop is recorded there and reaches the skip census the engine already reports at the end of every run.Only a non-zero value is a drop.
\hangindent=0ptasks for no hanging indent, which is exactly what this engine does; honouring it by doing nothing is correct, and reporting it would be noise on every document, since LaTeX's own\@endparenvand friends zero it routinely.⛔ The cache is maintained in
define, and the natural place would have been wrongCaching
\hangindent's register at the end ofloadTeXParams, beside\endlinecharand\escapechar, is the obvious thing to do.classkernel.goruns afterwards and declares\newdimen\hangindent, which rebinds the name to a different register.Measured, by building it the natural way and running the tests:
— and 104 once a document declares its own. The census would have reported nothing, for every document, for ever, while looking perfectly alive.
That is the same load-order trap that took
\prevdepth(#438) and\hangafter(#759), silently, both times.definesees every binding including the ones that come later, so the cache is maintained there. One string comparison per define is the price of not depending on the order of two files.The register index defaults to −1, not 0: register 0 is a real register somebody else holds, and a zero default would report every assignment to it as a dropped hanging indent. There is a test for that too.
⛔ A correction to #757, which this PR's issue got wrong
#757 says "
\parshapeis the general case and has the same status". It does not:\hangindentis declared and unread — silent.\parshapeis not defined at all, so it already goes through the undefined-command path and already appears in the census. Treating them as one item would have added a second report for something that is reported, and left the silent one silent. Those 91 papers are already visible; these 514 were not.Mutation
Building the cache the natural way reds three tests and names the registers:
⚠ What is not claimed
That a dropped indent costs any particular number of lines or pages. The breaker cannot be told a per-line measure at all yet (go-typeset/linebreak#11), so there is no second reading to compare against. This says what was asked for and refused, not what it cost — which is the whole point: it took an audit to find this, and an audit is the most expensive way to learn something the engine could have said on the first document that asked.
Checks
Refs #757.
Refs go-typeset/linebreak#11, which stays open on purpose and is not finished by this: that issue asks the breaker for a per-line measure, and this PR only makes the engine SAY it cannot use one. The two halves are deliberately separate — this one is actionable alone, and that one is in another organisation's repository.
🤖 Generated with Claude Code