Skip to content

compiler: \paragraph and \subparagraph are \@startsection levels 4 and 5 - #291

Closed
GoKubar wants to merge 1 commit into
mainfrom
agent/linux-engine-layout/sectioning-compiler
Closed

GoKubar wants to merge 1 commit into
mainfrom
agent/linux-engine-layout/sectioning-compiler

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

#258 rank 4 (fixtures/divergence-probes/min-paragraph): \paragraph and
\subparagraph were in KNOWN_UNIMPLEMENTED_COMMANDS, so every
\paragraph{...} raised an error and its argument fell through as ordinary
body text — not bold, indented by \parindent (+14.94 bp) and missing the
13.94 bp \@startsection puts above it, per occurrence. They are not exotic:
a run-in \paragraph is how solutions, proofs and notes are titled.

Split as the lane convention requires: this is the compiler PR; the
pipeline PR is #292 and must land with a vendor/compiler
re-pin past this commit.

What changed

article.cls lines 302-321 (report.cls and book.cls identical) declare five
\@startsection levels, not three. The two that were missing differ from the
others only in #5, which is -1em: a non-positive after-skip is what makes
\@xsect run the heading into the first line of the following paragraph
instead of ending a line of its own. That is a layout decision, so the block
this crate produces is the same Block::Heading as the other three, at level
4 and 5.

  • parser.rs: the sectioning arm takes both names; they join BUILT_INS and
    leave the unimplemented list.
  • xref.rs: article.cls lines 255-266 also declare
    \newcounter{paragraph}[subsubsection] and
    \newcounter{subparagraph}[paragraph], so a new \subsubsection resets
    them both. Every level steps here; which are printed is the consumer's
    \c@secnumdepth (article 3, report/book 2), which this crate does not model
    — the same simplification that already applied to subsubsection under
    report/book.
  • layout.rs (this crate's own v1 layout, not the exact route): levels 4 and
    5 are run-in. The heading does not end its line, \@xsect's \hskip -#5
    follows it and the next paragraph continues there with no \par and so no
    \parskip. after_run_in_heading carries that across the block boundary
    and is part of FlowState, so an incrementally reused block cannot resume
    into the wrong shape. Their number is not set: both levels are past every
    standard class's secnumdepth.
  • supported.rs plus the regenerated supported/{coverage.md, supported-latex.json} and docs/user/compiler.md (kernel commands
    164/410 → 166/410) — produced by
    crates/compiler/scripts/render_supported_latex.sh, not by hand.

Gates

NixOS linux-primary, CARGO_BUILD_JOBS=4.

gate result
crates/compiler cargo test --release --no-fail-fast 298 lib + every integration suite pass, 0 failed
tests/supported_latex.rs drift gates all 8 pass (inventory == parser arms; generated artifacts current)

New tests: the two commands are heading levels 4 and 5 with \the<name>
chained through all five counters; a new \subsubsection resets them; the
starred forms take no number and produce a heading rather than body text; and
in the v1 layout a run-in heading keeps its paragraph on the same line while
the \subsection above it does not.

What this does not do

The exact route (flashtex-render --v2) needs its own arm for a level-4/5
heading — it clamped Stylesheet::heading to levels 1..=3 and had no run-in
form at all. That is the pipeline PR, whose arm is inert until
crates/render-pipeline/vendor/compiler is re-pinned past this commit. With
both in place and the vendor mirrored locally, min-paragraph goes from max
|dx| 14.94 / |dy| 27.87 bp with 27 of 74 words within 0.5 bp to 0.01 / 0.01
bp with all 74
; the numbers are reported in full on the pipeline PR.

#258 rank 4 (`fixtures/divergence-probes/min-paragraph`): both commands were
in `KNOWN_UNIMPLEMENTED_COMMANDS`, so every `\paragraph{...}` raised an error
and its argument fell through as ordinary body text -- not bold, indented by
`\parindent` (+14.94 bp) and missing the 13.94 bp `\@startsection` puts above
it. They are not exotic: a `\paragraph` run-in heading is how solutions,
proofs and notes are titled.

article.cls lines 302-321 (report.cls and book.cls identical) declare five
`\@startsection` levels, not three. The two that were missing differ from the
others only in `#5`, which is `-1em`: a non-positive after-skip is what makes
`\@xsect` run the heading into the first line of the following paragraph
instead of ending a line. That is a layout decision, so the block this crate
produces is the same `Block::Heading` as the other three, at level 4 and 5.

- `parser.rs`: the sectioning arm takes `paragraph` and `subparagraph`; both
  join `BUILT_INS`, and they leave the unimplemented list.
- `xref.rs`: article.cls lines 255-266 also declare `\newcounter{paragraph}
  [subsubsection]` and `\newcounter{subparagraph}[paragraph]`, so a new
  `\subsubsection` resets them both. Every level steps here; which of them
  are *printed* is the consumer's `\c@secnumdepth` (article 3, report/book 2),
  which this crate does not model -- the same simplification that already
  applied to `subsubsection` under report/book.
- `layout.rs` (this crate's own v1 layout, not the exact route): levels 4 and
  5 are run-in. The heading does not end its line, `\@xsect`'s `\hskip -#5`
  follows it and the next paragraph continues there with no `\par` and so no
  `\parskip`; `after_run_in_heading` carries that across the block boundary
  and is part of `FlowState`, so an incrementally reused block cannot resume
  into the wrong shape. Their number is not set: both levels are past every
  standard class's `secnumdepth`.
- `supported.rs` plus the regenerated `supported/{coverage.md,
  supported-latex.json}` and `docs/user/compiler.md` (kernel commands
  164/410 -> 166/410).

**This is the compiler half.** The exact route (`flashtex-render --v2`) needs
its own arm for a level-4/5 heading -- it currently clamps `Stylesheet::heading`
to levels 1..=3 and has no run-in form at all -- and until
`crates/render-pipeline/vendor/compiler` is re-pinned past this commit it
cannot see these blocks. The pipeline PR is separate and must land with a
re-pin; measured before/after numbers for the reproducer are reported there.

Tests (`crates/compiler`, `cargo test --release --no-fail-fast`): 298 lib +
every integration suite pass, 0 failed. New: the two commands are heading
levels 4 and 5 with `\the<name>` chained through all five counters; a new
`\subsubsection` resets them; the starred forms take no number and produce a
heading rather than body text; and in the v1 layout a run-in heading keeps
its paragraph on the same line while the `\subsection` above it does not.

Implementation-Agent: Claude Opus 5 (engine layout lane, linux-primary / NixOS)
Commit-Executor: Claude Opus 5 via Claude Code (direct-agent Git execution
under the observed-Cursor-limit user override)
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
@GoKubar

GoKubar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded — the work is already on main.

Replacement: b891e7d plus the parser.rs dispatch arms

Closed by the integration lane while clearing a 219-PR backlog (112 of them drafts). If this is wrong, reopen it and tell me — I would rather be corrected than leave stale work buried.

— orchestrator-astra (Commander)

@GoKubar GoKubar closed this Sep 15, 2026
@GoKubar
GoKubar deleted the agent/linux-engine-layout/sectioning-compiler branch September 16, 2026 04:18
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