Repository navigation
render-pipeline: \paragraph/\subparagraph are run-in headings - #404
Conversation
|
Rebased onto current Corpus, 22 documents vs pdflatex, tolerance 0.5 bp:
Gates on the rebase: render-pipeline 270 passed / 0 failed / 2 ignored, class-geometry 4/0, compiler 581/0/4; amsmath 59/59, tabular 106/106, HW1 and HW2 3 pages / 0 errors / 0 font-FAILURE diagnostics. The
|
19ada19 to
c1e5dd4
Compare
`\paragraph` and `\subparagraph` are `\@startsection` with a *negative* after-skip (article.cls lines 406-414). `\@xsect`'s negative-`#5` branch never sets the head as a vertical block: it arms `\everypar`, which throws away the following paragraph's `\parindent` box (`{\setbox\z@\lastbox}`), sets `\hskip #3 <head>` in its place and then `\hskip -#5`. The head *is* the first words of that paragraph. That is what makes this a pipeline-only change. The compiler does not parse the command — it reports it and sets the braced argument as ordinary body text, which lands at the front of exactly the paragraph LaTeX runs the head into. The title words are already in the right place with the right spans; what was missing was the weight, the indent, the 1 em and the skip above. So: no new block type, no compiler change, no vendor re-pin. Before, the head was set at `\parindent` in the body face with an ordinary interword space after it and no skip above: dx **+14.94 bp**, dy **-13.94 bp** per occurrence. Four things the oracle pinned down, each measured against pdflatex (TeX Live 2025): * `#3` is `\z@` for `\paragraph` and `\parindent` for `\subparagraph`, so one head is flush and the other is not (72.000 against 86.944 at 10 pt). * The interword glue *inside* the head is the head font's `\fontdimen2`, not the body's: `ecbx1000` is 0.47 bp wider per space at 10 pt, which showed up as -0.93 bp on the head's third word. * `\addvspace` keeps whichever of the new skip and `\lastskip` is larger (`\@xaddvskip`); it does not add to it. Every `\paragraph{Solution.}` in `fixtures/real-world/ps-calculus` follows `\end{enumerate}`, whose `\endtrivlist` already contributed `\addvspace\@topsepadd`. Summing the two put each head ~1.5 bp low and dragged the rest of the page down — it cost that fixture 9 pp of `dy` before the `max` went in. * `\paragraph*`: the compiler does not consume the star, so it arrived as the first character of the title and pushed the line 5.73 bp right. `fixtures/divergence-probes/min-paragraph` is now exact: all 74 words within 0.5 bp in x and y (was 20 of 74). A probe with all three forms and one with a head after a list are exact too — every word within 0.01 bp. Corpus (22 real documents vs pdflatex, tolerance 0.5 bp): dx 84.47% -> 84.67%, dy 65.21% (unchanged), both 58.67% (unchanged), page counts 20/22 unchanged. `ps-calculus` is the only fixture that moves, and only in x: dx 66.02 -> 70.57. **The vertical drift in `ps-calculus` is not these heads.** It was attributed to "four missing `\paragraph` head skips" (-21.4 / -62.6 / -101.3 bp down pages 1-3). With the heads correct the drift is still -21 / -44..-83 / -98 bp: the four heads account for about 3.3 bp of it in total, because `\addvspace` absorbs the rest into the list's own skip. That residual has some other cause and is not touched here. Also removes the `expect("levels 1..=3")` in the heading table: the stylesheet now carries all five `\@startsection` levels, and `HeadingStyle` gains `run_in_after_em` for the negative after-skip. Gates: `cargo test --release --no-fail-fast` on render-pipeline 257 passed / 0 failed / 2 ignored (three new `run_in_headings` tests), class-geometry 4/0, compiler 577/0/4; amsmath 59/59, tabular 106/106, HW1 and HW2 3 pages / 0 errors / 0 font-FAILURE diagnostics. Implementation-Agent: Claude Opus 5 (lane nixos-graphics-sectioning, linux-primary) Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)
c1e5dd4 to
ce05ce0
Compare
|
Rebased onto Corpus, 22 documents vs pdflatex, tolerance 0.5 bp, baseline measured at
Gates: render-pipeline 274 passed / 0 failed / 2 ignored, class-geometry 4/0, compiler 581/0/4; amsmath 59/59, tabular 106/106, HW1 and HW2 3 pages / 0 errors / 0 font-FAILURE diagnostics. GitHub now reports the PR |
TeX Live 2026: with geometry, \pdfpagewidth=361.34999pt after
\setlength{\paperwidth}{5in}; without geometry \pdfpagewidth=614.295pt
(US Letter) while \paperwidth is 5in.
cargo test compiler --lib: ok. 327 passed; preamble_lengths: 9 passed;
supported_latex: 8 passed; full compiler suite green (4 ignored).
render-pipeline --lib: ok. 119 passed; 2 ignored; preamble_lengths_oracle:
5 passed; full pipeline suite green.
Next: git merge origin/main (#404 adapter.rs).
Implementation-Agent: cursor-agent cursor-grok-4.6
Commit-Executor: cursor-agent
Lane-Owner: daniel-parent (mac-m5pro-dq222)
Co-authored-by: Cursor <[email protected]>
Merged origin/main with ort; no conflicts. #404 auto-merged into adapter.rs (run-in paragraph/subparagraph headings). class-geometry was not edited. Commands and test result: lines: - cargo test --manifest-path crates/compiler/Cargo.toml --lib dimen_parsing test result: ok. 1 passed; 0 failed; 0 ignored - cargo test --manifest-path crates/compiler/Cargo.toml --test preamble_lengths test result: ok. 9 passed; 0 failed; 0 ignored - cargo test --manifest-path crates/render-pipeline/Cargo.toml --lib adapter::tests test result: ok. 25 passed; 0 failed; 2 ignored - cargo test --manifest-path crates/render-pipeline/Cargo.toml --lib test result: ok. 119 passed; 0 failed; 2 ignored - cargo test --manifest-path crates/render-pipeline/Cargo.toml --test run_in_headings test result: ok. 3 passed; 0 failed; 0 ignored - cargo test --manifest-path crates/render-pipeline/Cargo.toml --test preamble_lengths_oracle test result: ok. 5 passed; 0 failed; 0 ignored The two ignored adapter tests are known limits (\input preambles; \@setlength). Next step: push this lane branch. No further code changes. Implementation-Agent: cursor-agent cursor-grok-4.6 Commit-Executor: cursor-agent Lane-Owner: daniel-parent (mac-m5pro-dq222) Co-authored-by: Cursor <[email protected]>
What
\paragraphand\subparagraphare\@startsectionwith a negative after-skip (article.cls lines 406-414).\@xsect's negative-#5branch never sets the head as a vertical block: it arms\everypar, which throws away the following paragraph's\parindentbox ({\setbox\z@\lastbox}), sets\hskip #3 <head>in its place and then\hskip -#5. The head is the first words of that paragraph.That is what makes this a pipeline-only change. The compiler does not parse the command — it reports it and sets the braced argument as ordinary body text, which lands at the front of exactly the paragraph LaTeX runs the head into. The title words are already in the right place with the right spans; what was missing was the weight, the indent, the 1 em and the skip above.
Before: the head was set at
\parindentin the body face with an ordinary interword space after it and no skip above — dx +14.94 bp, dy −13.94 bp per occurrence.Four things the oracle pinned down
Each measured against pdflatex (TeX Live 2025):
#3differs by level.\z@for\paragraph,\parindentfor\subparagraph— 72.000 against 86.944 at 10 pt.\fontdimen2, not the body's.ecbx1000is 0.47 bp wider per space at 10 pt; this showed as −0.93 bp on the head's third word until theItem::Spacestyle was switched too.\addvspacetakes the max, not the sum (\@xaddvskip). Every\paragraph{Solution.}inps-calculusfollows\end{enumerate}, whose\endtrivlistalready contributed\addvspace\@topsepadd. Summing them put each head ~1.5 bp low and dragged the rest of the page down — it cost that fixture 9 pp ofdybefore themaxwent in.\paragraph*: the compiler does not consume the star, so it arrived as the first character of the title and pushed the line 5.73 bp right.Oracle evidence
fixtures/divergence-probes/min-paragraph, words within 0.5 bp in x and y: 20/74 → 74/74. A probe with all three forms, and one with a head after a list, are exact too — every word within 0.01 bp.\paragraphhead x / baseline\subparagraphhead x\parindent, 86.944)\paragraph*head x*)\end{enumerate}(11 pt)Corpus
22 real documents vs pdflatex, tolerance 0.5 bp:
ps-calculusis the only fixture that moves, and only in x: dx 66.02 → 70.57.The vertical drift in
ps-calculusis not these headsIt was attributed to "four missing
\paragraphhead skips" (−21.4 / −62.6 / −101.3 bp down pages 1–3). With the heads correct the drift is still −21 / −44..−83 / −98 bp: the four heads account for about 3.3 bp in total, because\addvspaceabsorbs the rest into the list's own skip. That residual has another cause and is not touched here — worth its own lane.Files touched
crates/render-pipeline/src/adapter.rs(RunIn,run_in_heading_at,apply_run_in_heading, theUnitKind::Paragrapharm)crates/render-pipeline/src/style.rs(HeadingStyle::run_in_after_em; the heading table now carries all five\@startsectionlevels, removing theexpect("levels 1..=3"))crates/render-pipeline/tests/run_in_headings.rs(new, 3 tests)No
crates/render-pipeline/vendor/*change; no compiler-side change; no vendor re-pin required.Known follow-up (not this PR): the compiler still emits
unsupported_feature: \paragraph is not supported by this compiler version. The layout is now correct, so that diagnostic is stale noise in the Problems panel. Removing it is acrates/compilerchange and therefore a separate PR plus a vendor re-pin — filed separately rather than bundled here.Gates
cargo test --release --no-fail-fastwithFLASHTEX_FONT_DIRS/FLASHTEX_TFM_DIRSset:crates/render-pipeline257 passed / 0 failed / 2 ignoredcrates/class-geometry4 passed / 0 failedcrates/compiler577 passed / 0 failed / 4 ignoredCoordination
Touches
adapter.rs,style.rsand one new test file. Independent of #395, #396 and #399. Does not touch the per-page vertical constant inlmodern-report/plain-article; neither fixture moves at all here.🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu