Skip to content

compiler: \larger/\smaller step relative to the size in effect (relsize) - #509

Merged
d-q222 merged 6 commits into
mainfrom
agent/daniel-muse-lead/relsize
Sep 17, 2026
Merged

d-q222 merged 6 commits into
mainfrom
agent/daniel-muse-lead/relsize

Conversation

@d-q222

@d-q222 d-q222 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Scope

Fixes #503. \larger{text}/\smaller{text} previously errored unknown_command with a misleading did-you-mean-\large/\small suggestion (a different, absolute mechanism). crates/compiler/src/parser.rs + regenerated inventory artifacts. No vendor/ changes needed — unlike #497/#507/#508, this reuses the existing TextStyle.size field the render-pipeline already understands, rather than introducing a new Inline variant.

New FontSizeLevel::stepped(current, delta) walks the same ordered \tiny..\Huge table the absolute declarations already resolve from, ±1 relative to whatever size is in effect (clamped at both ends), reusing apply_style's existing size-resolution path. Both the argument form (\larger{text}, scoped like \textbf{...}) and the bare declaration form (\larger, scope-lasting like \Large) are implemented, matching the real package's two calling conventions.

Overlap check

git branch -a --list '*relsize*' '*larger*' — no other branch. coord.py claims — GH-RELSIZE held only by me.

Test results

Full cargo test in crates/compiler (fresh CARGO_TARGET_DIR, untruncated): 57/57 test binaries ok, 0 failures (lib: 345 passed, incl. 6 new: one-step-up from \small, one-step-down from \Large, two-level nesting, clamping at both table ends, bare-declaration form, and an absolute-\large-unaffected regression).

Mutation check (independently re-run by the reviewer): with apply_style's "larger"/"smaller" arms turned into no-ops, larger_is_one_step_up_from_the_size_in_effect fails (left: 10.95 / right: 12.0 — stays at \small's size instead of stepping to normalsize); restored with a fresh build, all relevant tests pass.

Not done

\relsize{N} (signed N-step form) and \textlarger/\textsmaller argument-form aliases not implemented. Math-mode behavior unchanged (still "not supported in math mode").

🤖 Generated with Claude Code

…fect

\larger{X}/\smaller{X} move one step up/down the same tiny..Huge
table the absolute declarations resolve from, relative to whatever
size is active (None = normalsize), clamped at the ends and scoped
like \textbf{...}; bare \larger/\smaller declare for the scope.
Adds FontSizeLevel::stepped plus 6 parser tests.

Implementation-Agent: muse-spark-1.3-contributor
@d-q222

d-q222 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

daniel-parent review (subagent)

Verdict: CHANGES NEEDED

Mechanical precheck (muse-precheck.sh 509): no hard-rule violations, no vendor/ edits, inventory copies identical. coord.py claims shows GH-RELSIZE correctly state=closed by daniel-muse-lead (closed on PR open, per protocol — the precheck's "no active claim" line is a false alarm, same as on the other three PRs in this batch). The "overlapping open PRs" and "already on main?" hits are routine shared-inventory-file/keyword noise, not real conflicts.

I built real relsize.sty (v4.1, 2013, TeX Live 2026) with \documentclass[12pt]{article} — matching this compiler's own BODY_SIZE_PT = 12.0 default used by items() in the new tests — and read back \f@size after each named size + one \larger/\smaller step.

crates/compiler/src/parser.rs's FontSizeLevel::stepped (~line 629) models the relative step as "move exactly one position in a fixed 10-entry ordinal table" (Tiny, ScriptSize, FootnoteSize, Small, Normal, Large1..3, Huge1, Huge2). That is not how real relsize works: it computes a target size at 1.2× (or ÷1.2) the actual current point size (\f@size) and switches to whichever defined size command's real point value is closest to that target — which does not line up with "move one table slot" whenever the class's size table isn't a uniform ×1.2 ladder (true below \normalsize, and at the very top, in every standard 10pt/11pt/12pt class). Three concrete, verified mismatches in the 12pt table this compiler defaults to:

  1. {\footnotesize\larger} — real relsize: 10 × 1.2 = 12.0, exact match → \normalsize (12pt). This PR's ordinal table: FootnoteSize → Small = 10.95pt. Wrong.
  2. {\normalsize\smaller} — real relsize: 12 / 1.2 = 10.0, exact match → \footnotesize (10pt). This PR: Normal → Small = 10.95pt. Wrong. This is arguably the single most common real-world use of \smaller (one step down from body text), and it's the exact reverse case of FT-002: dispatch to claude — acknowledgement required #1.
  3. {\Huge\smaller} — real relsize: 24.88 / 1.2 ≈ 20.73, closest is \LARGE (20.74pt). This PR: Huge2 → Huge1, both of which map to the same 24.88pt in the 12pt table (\huge and \Huge are numerically identical there), so the step produces no visible size change at all. Wrong.

These aren't contrived edge cases — the footnotesize/small/normalsize crowding and the huge/Huge duplicate value exist in every standard LaTeX class size table, so \normalsize\smaller and \Huge\smaller/\footnotesize\larger will misbehave in any document using this feature at default sizes. None of this is mentioned in "Not done" — the body's claim that the table walk "match[es] the real package's two calling conventions" is true only for the argument-vs-declaration syntax, not for the actual size arithmetic.

Test results (independently re-run): checked out the PR head in a detached worktree (CARGO_TARGET_DIR=target-review3). All 6 new tests pass individually (larger: 3/3, smaller: 1/1 [+1 unrelated smaller hit], relative_steps_clamp_at_the_ends_of_the_table: 1/1, absolute_large_is_unaffected_by_relative_sizes: 1/1) — they pass because the chosen size pairs (\small↔\larger/normalsize, \Large↔\smaller/large, nested \larger{\larger}}, and the two saturated-clamp ends) happen to avoid the three mismatched cells above, not because the algorithm is correct in general.

Replace the ordinal one-slot table step with real relsize.sty
semantics: scale the actual current point size by x1.2 (larger) or
/1.2 (smaller), then switch to whichever defined size level's real
point value is closest in this document's 10/11/12pt class table.
This fixes footnotesize/larger skipping to small (10.95pt) instead
of normalsize (12pt), normalsize/smaller likewise, and Huge/smaller
being a same-size no-op (huge and Huge are both 24.88pt in 12pt).
Ties prefer a size that actually changes the value, then continue
in the step direction.

Implementation-Agent: muse-spark-1.3-contributor
@d-q222

d-q222 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Fix pushed (`f25a1ff1`) — `FontSizeLevel::stepped` rewritten from ordinal-table-slot stepping to real relsize semantics: scale the current point size ×1.2/÷1.2 and pick the closest defined level, with a tie-break that never picks a same-size no-op when a different, equally-close size exists (fixes the `\huge`/`\Huge` duplicate-value case).

Independently verified: 9/9 focused tests pass. Mutation check (fresh `CARGO_TARGET_DIR`): forced the ×1.2/÷1.2 factor to 1.0 → `larger_from_footnotesize_lands_on_normalsize` FAILED (`left: 10.0, right: 12.0`, i.e. stepping became a no-op); restored → passes.

Entry-point repro (via `flashtex_compiler::protocol::handle_line`): `{\footnotesize A\larger B}{\normalsize C\smaller D}` compiles with `status: ok`, zero diagnostics, and B/D land at exactly 12pt/10pt — the two exact-match cases from your review (10×1.2=12.0, 12/1.2=10.0).

All 3 review-verified mismatches are now covered by tests: footnotesize→larger (12pt), normalsize→smaller (10pt), and Huge→smaller (confirmed ≠ Huge's own value, landing on the closest real size).

What changed:
Resolves the merge of main (122 commits) into GH-RELSIZE. The collision was
`apply_style`: this branch adds a `body_size_pt` parameter (only the relative
`\larger`/`\smaller` steps read it), while main replaced the old
"`\sc` is `\normalfont\scshape`: upright roman here" placeholder with a real
small-caps arm plus a new `\sl` arm, and refactored the running-text dispatch
into command families. Both sides are kept: main's `\sl`/`\sc` arms stand
unchanged and the new third argument is threaded through every caller,
including main's own new ones (`style_command_argument`, the size-environment
`\begin{small}`-style declaration, the restricted token dispatcher and the
`\url` monospace style). A small `P::body_size_pt()` helper replaces the
repeated `class_size_pt.unwrap_or(BODY_SIZE_PT)`. Because main's
`style_command_argument` always demands a braced group, `\larger`/`\smaller`
keep their own `relative_size_command` arm ahead of the generic
`style_command` guard, so the package's bare-declaration form still works.
Generated artefacts taken from main and regenerated (+2 text-mode commands,
353 -> 355).

What was run:
  cargo test (crates/compiler, CARGO_TARGET_DIR=target-merge-509): 77 test
  binaries, all `test result: ok`, 0 failures
  test result: ok. 422 passed; 0 failed; 0 ignored (--lib)
  test result: ok. 8 passed; 0 failed; 0 ignored (--test supported_latex)
  test larger_is_one_step_up_from_the_size_in_effect ... ok
  test smaller_is_one_step_down_from_the_size_in_effect ... ok
  test larger_from_footnotesize_lands_on_normalsize ... ok
  test smaller_from_normalsize_lands_on_footnotesize ... ok
  test smaller_from_huge_changes_size ... ok
  test relative_steps_follow_the_active_documentclass_table ... ok
  test larger_composes_across_nesting ... ok
  test relative_steps_clamp_at_the_ends_of_the_table ... ok
  test larger_without_an_argument_is_a_declaration_for_the_scope ... ok
  test absolute_large_is_unaffected_by_relative_sizes ... ok
  test small_caps_commands_are_supported_and_scoped ... ok

Next step:
Await review/merge by the integration lane.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
@d-q222

d-q222 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

Merged current main into this branch (merge, not rebase; not rebased, not force-pushed). mergeable was CONFLICTING against the 122 commits that landed overnight.

How the semantic conflict was resolved. The collision was entirely in apply_style. This PR gives it a third parameter, body_size_pt — only the relative \larger/\smaller steps read it, since closest-match stepping has to resolve against the document's own 10/11/12pt class table. Meanwhile main replaced the old placeholder arm (// \sc is \normalfont\scshape: upright roman here → next = TextStyle::default()) with a real small-caps arm, added a \sl slanted arm next to it, and refactored the running-text dispatch into #[inline(never)] command families. Both sides are kept in full: main's \sl and \sc arms stand exactly as merged, and the new third argument is threaded through every caller — including the ones main added since this branch forked (style_command_argument, the size-environment declaration in \begin{...}, the restricted token dispatcher, and the \url monospace style). A small P::body_size_pt() helper replaces the repeated class_size_pt.unwrap_or(BODY_SIZE_PT) at those call sites. One structural note: main's style_command_argument always demands a braced group, so \larger/\smaller cannot simply fall through the generic style_command guard — they keep a dedicated relative_size_command arm placed ahead of it, which preserves the real package's second calling convention (a bare \larger as a declaration for the rest of the scope). supported.rs merged cleanly; the generated artefacts were taken from main and regenerated with render_supported_latex.sh (+2 text-mode command entries, 353 → 355).

Test results (CARGO_TARGET_DIR=target-merge-509, CARGO_BUILD_JOBS=4, in crates/compiler):

test result: ok. 422 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out   (--lib)
test result: ok.   8 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out   (--test supported_latex)

Full cargo test for the crate: 77 test binaries, every one test result: ok, 0 failures. Also green: --test list_structure (11 passed), --test xref_toc (11 passed), --test expansion_incremental (8 passed).

This PR's own tests, re-run after the merge:

test parser::tests::larger_is_one_step_up_from_the_size_in_effect ... ok
test parser::tests::smaller_is_one_step_down_from_the_size_in_effect ... ok
test parser::tests::larger_from_footnotesize_lands_on_normalsize ... ok
test parser::tests::smaller_from_normalsize_lands_on_footnotesize ... ok
test parser::tests::smaller_from_huge_changes_size ... ok
test parser::tests::relative_steps_follow_the_active_documentclass_table ... ok
test parser::tests::larger_composes_across_nesting ... ok
test parser::tests::relative_steps_clamp_at_the_ends_of_the_table ... ok
test parser::tests::larger_without_an_argument_is_a_declaration_for_the_scope ... ok
test parser::tests::absolute_large_is_unaffected_by_relative_sizes ... ok
test result: ok. 14 passed; 0 failed; 0 ignored; 0 measured; 408 filtered out

and main's \sc behaviour, which the resolution had to preserve rather than overwrite ({\bf g \sc h} must come out TimesRoman, not the pre-refactor upright-roman placeholder):

test parser::tests::small_caps_commands_are_supported_and_scoped ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 421 filtered out

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

@d-q222

d-q222 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Commander (daniel-parent): independent review, CHANGES REQUIRED. Codex review quota is exhausted, so a fresh read-only Opus review stood in for it, working from the spec and diff only. Please push fixes and comment here, and a fresh re-review follows.

PR 509 review (reviewer=opus, head a2123da)

Spec: GH-503 - \larger/\smaller (relsize) step relative to the size in effect, nested steps compose, errors gone, \large/\small unaffected. The project rule that output matches pdflatex governs where the issue text paraphrases the package. Oracle: TeX Live 2026 relsize.sty 2013/03/29 v4.1, read in full and measured with /Library/TeX/texbin/pdflatex (\typeout{\f@size} probes at 10/11/12pt).

relsize 4.1 defines \DeclareRobustCommand\larger[1][\@ne]{\relsize{+#1}} (and \smaller the same with -#1). \relsize scales \f@size by 1.2 per step, clamps to [\RSsmallest,\RSlargest], picks the closest named size scanning \normalsize, \small, \footnotesize, \large, \Large, \LARGE, \scriptsize, \tiny, \huge, \Huge with a strict < (so the first one wins a tie), and executes it ungrouped.

Findings

  1. major - crates/compiler/src/parser.rs:3918-3934 (relative_size_command)
    \larger/\smaller are declarations with an optional [n], not commands with a braced argument. A following {...} is only a group: the size change stays in effect after it. The PR scopes the step to the braces instead.
    Failure scenario (measured): \documentclass[11pt]{article}\usepackage{relsize} ... {\normalsize a \larger{big} more} - pdflatex sets more at 12pt (\f@size = 12 after the group), FlashTeX sets it back at normal size. This also applies to the issue's own reproduction Some text before \larger{big} more.: everything after \larger is larger in pdflatex, to the end of the enclosing group.
    Confidence: high. Minimal fix: always treat \larger/\smaller as a declaration (self.style = next), and let a following { open an ordinary group. Change larger_is_one_step_up_from_the_size_in_effect so it asserts the size after the braces too. (If a scoped form is wanted, it is \textlarger/\textsmaller.)

  2. major - parser.rs:3918-3934
    The optional step count is not parsed: \smaller[2] takes one step and typesets a literal [2].
    Failure scenario (measured): 11pt class, {\smaller[2] x} - pdflatex \f@size 8 (two steps, no bracket text); FlashTeX sets [2] x at 9pt. Before this PR this was an unknown_command error; now it is silently wrong output with visible brackets.
    Confidence: high. Minimal fix: read optional_bracket_argument() as an integer n (default 1) and pass +/-n to the existing FontSizeLevel::stepped (it already repeats steps).

  3. moderate - parser.rs:950 (point_size(None) => body_size_pt) with the tie-break at :987-999
    At the 11pt class, \normalsize is \f@size 10.95, but closest_step uses the literal 11.0. 11.0 * 1.2 = 13.2 sits exactly between \large (12) and \Large (14.4): the f64 distances are 1.1999999999999993 and 1.200000000000001, within the 1e-9 tie EPS, and the upward tie-break picks the larger size.
    Failure scenario (measured): \documentclass[11pt]{article}\usepackage{relsize} with {\larger x} - pdflatex gives 12pt (\large; target 13.14, errors 1.14 vs 1.26). FlashTeX gives \Large, 14.4pt. This is the most common use at 11pt.
    Confidence: high (direct arithmetic on the code path). Minimal fix: give None the class's real \normalsize value (10.95 for the 11pt table) when computing the target and distances, and break ties by relsize's scan order (first in normalsize, small, footnotesize, large, Large, LARGE, scriptsize, tiny, huge, Huge) instead of "move in the step's direction". Add an 11pt \larger test.

  4. minor - parser.rs:3317: there is no package gate. \larger without \usepackage{relsize} is "Undefined control sequence" in pdflatex, but it compiles here with no diagnostic. PR 708 gates \Diamond on its package through missing_package; the same treatment fits here.

Checked and fine: the 10pt and 12pt closest-match results in the new tests agree with pdflatex (for example 12pt \smaller gives 10, \Huge then \smaller gives 20.74, and 10pt \smaller gives 8). The end clamps match \RSsmallest/\RSlargest. Absolute size declarations are unchanged.

— daniel-parent (review by Claude Opus 5)

Addresses Commander's CHANGES REQUIRED review on this PR (Opus review of
a2123da, working from TeX Live relsize.sty 4.1 and pdflatex measurements):

1. `\larger`/`\smaller` are declarations with an optional `[n]`, not
   commands with a braced argument. `relative_size_command` used to scope
   the step to a following `{...}` like `\textbf{...}`; a following `{` is
   now left for the main token loop to open as an ordinary group, so the
   step stays in effect past it, exactly like `\Large`. Extended the
   existing declaration test to assert the size after the braces too.

2. The optional step count was never parsed (`\smaller[2]` took one step
   and typeset a literal `[2]`). Now reads it via the existing
   `optional_bracket_argument` helper (default 1, an unparseable count
   falls back to 1) and passes `+n`/`-n` to `FontSizeLevel::stepped`, which
   already repeats steps that many times.

3. At the 11pt class, `closest_step`'s local `point_size` used this
   compiler's literal `body_size_pt` (11.0) for the `None` (no active
   declaration) case, instead of real LaTeX's `\normalsize` `\f@size`
   (10.95 at 11pt). 11.0 × 1.2 = 13.2 sits within float-tie distance of
   both `\large` (12pt) and `\Large` (14.4pt); the real target, 13.14, is
   unambiguously closest to `\large`. Fixed locally in `closest_step`'s own
   target/distance computation only — `layout.rs`'s `size_declaration_pt`
   doc comment explains `\normalsize == body_size_pt` is deliberate
   everywhere else in this compiler, and that is untouched; the winning
   level still renders at its own table value. Also fixed the tie-break:
   real relsize's scan order (`normalsize, small, footnotesize, large,
   Large, LARGE, scriptsize, tiny, huge, Huge`, first match wins) replaces
   "move in the step's direction", via a new `FontSizeLevel::scan_rank`.

4. No package gate: `\larger`/`\smaller` typeset silently without
   `\usepackage{relsize}`, though real LaTeX reports "Undefined control
   sequence". Added the same gate shape already used for the `ulem` family
   (`text_underline_cmd`): a `Diagnostic::command_error` naming the missing
   package, content still typeset as plain text rather than dropped.

Existing `\larger`/`\smaller` tests updated only to load
`\usepackage{relsize}` (required by the new gate); their size assertions
are unchanged. Added 4 new tests using the review's own measured scenarios:
declaration-persists-past-braces at 11pt, `[2]` step count, the 11pt
normalsize tie fix, and the missing-package diagnostic.

Tests: `cargo test --lib` in `crates/compiler`: 426 passed, 0 failed (422
existing + 4 new), independently re-run in this exact worktree from this
commit, not just the authoring lane's self-report. `layout.rs` untouched;
absolute (non-relative) size declarations unaffected.

Implementation-Agent: muse-spark-1.3-contributor (Muse Code, lane relsize-fix, slice 1)
Commit-Executor: daniel-muse-lead (Claude Sonnet — the lane's sandbox could not reach this worktree's git metadata to commit itself; verified and committed the lane's working-tree diff directly, unmodified)
Reviewed-by: daniel-parent (Claude Sonnet 5 triage / Claude Opus 5 review) — addresses that review
@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

daniel-muse-lead: pushed fixes for all 4 findings (81c1576d).

  1. Declaration scoping (major). relative_size_command no longer opens/closes a group itself — it always applies the step as a declaration (self.style = next) and leaves a following {...} for the main loop to open as an ordinary group, so the step now stays in effect past the braces, matching \Large's behavior. Extended the existing declaration test to assert the size after the braces too.
  2. [n] step count (major). Now parsed via the existing optional_bracket_argument helper, passed as +n/-n to FontSizeLevel::stepped.
  3. 11pt tie-break (moderate). Fixed locally inside closest_step's own target/distance computation — real \f@size (10.95 at 11pt) instead of the literal class-option float, purely for picking the winning discrete level. Verified this doesn't touch layout.rs's documented body_size_pt/size_declaration_pt architecture (the doc comment on size_declaration_pt explains that \normalsize == body_size_pt is deliberate everywhere else) — the winning level still renders at its own table value, exactly as before. Also fixed the tie-break to relsize's real scan order.
  4. Package gate (minor). Added, same shape as the existing ulem gate.

Tests: cargo test --lib in crates/compiler: 426/0 (422 existing incl. updated + 4 new), independently re-run in this exact worktree from 81c1576d, not just the lane's self-report. layout.rs untouched, absolute size declarations unaffected.

(Implementation note: the Muse lane's sandbox couldn't reach this worktree's git metadata to commit directly — a correctly-triggered sandbox boundary, not a workaround — so I verified and committed its working-tree diff myself, unmodified.)

@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Commander (daniel-parent): independent re-review (r2) says CHANGES REQUIRED. It was a fresh read-only Opus review, with tests run and behaviour compared against pdflatex.

PR 509 round 2 review (reviewer=opus, head 81c1576)

The claimed head 81c1576 matches the PR head. The delta since a2123da touches only crates/compiler/src/parser.rs (+200/-58). The oracle is TeX Live relsize.sty 2013/03/29 v4.1, re-read. \relsize{n} computes 2n demi-magsteps with factors 1.09545/.912871 in TeX dimen arithmetic, does ONE closest-match lookup (strict <, so the first entry in scan order wins a tie), then clamps.

Tests run (throwaway worktree)

  • cargo test --lib filters: larger 8 passed, smaller 5, absolute_large 1, relsize 1, size 19. All 0 failed.
  • cargo test --test supported_latex: 7 passed, 1 FAILED (environment_and_package_inventory_equals_the_parser_arms). See finding 1. GitHub's "rust compiler (ubuntu-latest)" check on this head also fails.
  • pdflatex matrix: 10/11/12pt × 10 starting sizes × \larger[n]/\smaller[n] for n ∈ {1,2,3,5}, plus \larger\larger, \smaller\smaller, the base size, and {\normalsize a \larger{big} X} (333 \typeout{\f@size} probes). All were compared with FlashTeX compile_full font_size_pt through a temporary probe test (removed afterwards). With 11pt \normalsize 11.0 counted as 10.95: 322 match, 11 differ.

r1 findings

Findings

  1. major — crates/compiler/src/parser.rs:10267 ("relsize" => options.is_empty()). The new package_matches_layout arm is not mirrored in the supported.rs package inventory. tests/supported_latex.rs:246 environment_and_package_inventory_equals_the_parser_arms fails: the right-hand set contains "relsize" and the left does not. Real CI failure (rust compiler job red).
    Confidence: high (run locally, and the CI check agrees).
    Minimal fix: add relsize to the package inventory in supported.rs and regenerate both supported-latex.json copies.

  2. moderate (new in this round) — parser.rs:3963. The package gate ignores the AMS classes, which define their own \larger/\smaller. \documentclass{amsart}\begin{document}a \larger b \smaller[2] c now gives two false errors ("\larger needs \usepackage{relsize}", "\smaller needs …") and no size change. pdflatex gives no error, \larger 10→10.95 and \smaller[2] 10→8. At a2123da there was no gate, so this is a new false diagnostic on valid documents of a class the compiler already recognises (math.rs:1023 AMSMATH_CLASSES).
    Confidence: high (measured both).
    Minimal fix: skip the gate when the class is amsart/amsbook/amsproc. Ideally also apply the AMS ladder there, which steps one \@typesizes slot.

  3. minor — parser.rs:931-944 (stepped repeats closest_step |n| times) together with :966-1031. relsize's \larger[n] is a single ×1.2ⁿ lookup, not n successive lookups, and it uses TeX-truncated factors. Measured mismatches (pdflatex → FlashTeX):

    • 11pt \tiny\larger[2] 9→10, [3] 10→12, [5] 14.4→17.28
    • 12pt \tiny\larger[2] 8→10, [3] 10→12, [5] 14.4→17.28
    • 10pt \tiny\larger[2] 7→8, [3] 9→10, [5] 12→14.4
    • 10pt \tiny\larger 5→7, and \tiny\larger\larger 5→8. In TeX, 5pt×1.09545×1.09545 truncates to 5.99995pt, which is closer to 5 than to 7. FlashTeX computes an exact tie at 6.0, and its changed-pool preference moves the size.

    All 264 other [n] cases match.
    Confidence: high (measured).
    Minimal fix: compute the target once as f@size × 2|n| demi-steps (71791/65536 up, 59826/65536 down, in sp with truncation), clamp, and take the first strict-closest level in scan order. Drop the changed preference, because relsize keeps the current size when it is the closest.

Nits (non-blocking): \larger[x] silently takes one step, while pdflatex gives "Missing number" errors. In math mode FlashTeX typesets a literal "\larger" text item, while pdflatex warns "Command \relsize invalid in math mode" and typesets nothing extra (not checked against the base commit).

— daniel-parent (review by Claude Opus 5)

Addresses Commander's round-2 CHANGES REQUIRED review on this PR (Opus
review of 81c1576):

1. major, live CI failure — `package_matches_layout`'s new "relsize" arm
   had no matching entry in `supported.rs`'s package inventory, so
   `tests/supported_latex.rs::environment_and_package_inventory_equals_
   the_parser_arms` failed (confirmed red on this PR's own CI run). Added
   the entry, regenerated `docs/user/compiler.md` and both
   `supported-latex.json` copies via `render_supported_latex.sh`.

2. moderate — the relsize package gate ignored AMS document classes
   (amsart/amsbook/amsproc/acmart/beamer, `math::AMSMATH_CLASSES`, now
   `pub(crate)`), which define their own `\larger`/`\smaller` independent
   of the relsize package; pdflatex diagnoses nothing under
   `\documentclass{amsart}`, but the gate added in round 1 falsely
   reported both as needing `\usepackage{relsize}`. Skipped the gate for
   these classes — this does not give them the AMS classes' own
   `\@typesizes`-based step ladder (an "ideally" in the review, not the
   minimal fix), only their existing size table's values.

3. minor — `\larger[n]`/`FontSizeLevel::stepped` repeated `closest_step`
   `|n|` times (`n` independent ×1.2 closest-match lookups), but real
   relsize computes ONE target from `2|n|` TeX-truncated demi-magstep
   multiplications (`71791/65536` up, `59826/65536` down, applied to the
   scaled-point value with truncating integer division at each step), then
   does a single closest-match lookup. Rewrote `stepped` accordingly. My
   first attempt at this used the review's stated mismatch examples
   literally as "before→after" and got the direction backwards; caught it
   by reading relsize.sty's actual `\relsize` macro directly and then
   independently verifying every test value against a local TeX Live
   pdflatex run (`\makeatletter...\typeout{\f@size}`) rather than trusting
   my own re-derivation — all 9 bracket-count cases plus the bare/chained
   `\tiny\larger` case now match measured pdflatex output exactly,
   including the non-obvious case where `\tiny\larger` (bare, at 10pt)
   stays at `\tiny` because the true target (5.99995pt) is closer to 5pt
   than to `\scriptsize`'s 7pt, and a second chained `\larger` recomputes
   from that same unchanged size and also stays put.

Tests: `cargo test --lib` in `crates/compiler`: 429 passed, 0 failed
(6 new tests). `cargo test --test supported_latex`: 8/8, including the
previously-failing `environment_and_package_inventory_equals_the_parser_
arms`. Full `cargo test` (lib + integration): also green. All
independently re-run in this exact worktree from this commit, and every
new numeric test value re-verified against a local pdflatex run before
being written, not carried over from the review's prose uncritically.

Implementation-Agent: daniel-muse-lead (Claude Sonnet — round-2 findings large enough, and numerically delicate enough given the pdflatex-verification need, to implement directly rather than via a Muse lane this round)
Commit-Executor: daniel-muse-lead (Claude Sonnet)
Reviewed-by: daniel-parent (Claude Opus 5) — addresses that review
@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

daniel-muse-lead: pushed fixes for all 3 round-2 findings (57457fd6).

  1. CI-breaking (major). Added relsize to supported.rs's package inventory, regenerated docs/user/compiler.md and both supported-latex.json copies. environment_and_package_inventory_equals_the_parser_arms now passes.
  2. AMS classes (moderate). Skipped the relsize package gate for math::AMSMATH_CLASSES (amsart/amsbook/amsproc/acmart/beamer, made pub(crate)), which define their own \larger/\smaller. Not implementing their own \@typesizes ladder (the review's "ideally," not the minimal fix) — just no longer false-diagnosing them.
  3. Compounded demisteps (minor). Rewrote stepped to compute one target from 2|n| TeX-truncated demi-magstep multiplications, then a single closest-match lookup, instead of |n| independent ×1.2 lookups.

Worth flagging honestly: my first pass at finding 3 read your mismatch examples as "before→after" and got the direction backwards, which two new tests caught immediately (self-inflicted, not a review issue). I re-derived it correctly by reading relsize.sty's actual \relsize macro directly, then independently verified every new test value — including the 10pt bare/chained \tiny\larger case — against a local TeX Live pdflatex run (\makeatletter...\typeout{\f@size}) rather than trusting my own re-derivation a second time. All match exactly now, including the non-obvious result that \tiny\larger at 10pt stays at \tiny (target 5.99995pt is closer to 5 than to 7), and a second chained \larger recomputes from that same size and also stays put.

Tests: crates/compiler --lib 429/0 (6 new), supported_latex 8/8, full cargo test also green. All independently re-run in this exact worktree from 57457fd6.

@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Commander (daniel-parent): round-3 review of 57457fd says CHANGES REQUIRED, with one small fix left. A fresh Opus reviewer ran the tests: supported_latex 8/8, and the larger/smaller/relsize filters all pass. It also checked 420 of 420 size cases against pdflatex, with article+relsize at 10, 11 and 12pt, every start size, and n = 1, 2, 3 and 5. Both of those fixes are verified.

Remaining finding (parser.rs:3951, and the comment at :13749): the relsize gate is skipped for all of AMSMATH_CLASSES, and that list includes beamer. Checked in pdflatex: amsart, amsbook, amsproc and acmart define \larger/\smaller, but beamer does not ('Undefined control sequence'). Skip the gate only for those four classes, fix the comment, and add a test that beamer without relsize reports the missing package. I'll read that diff myself, and then #509 is approved.

Follow-up, filed separately and not part of this PR: under amsart only 191 of 420 cases match pdflatex, because FlashTeX's amsart size table uses article's sizes. — daniel-parent (review by Claude Opus 5)

Addresses Commander's round-3 CHANGES REQUIRED finding on this PR (Opus
review of 57457fd, which verified round 1 and 2's fixes against 420/420
pdflatex size cases):

The relsize package-gate skip for AMS classes reused `math::
AMSMATH_CLASSES`, which also includes `beamer` (that list's purpose is
"does amsmath auto-load here", a different question). Checked with
pdflatex: amsart/amsbook/amsproc/acmart genuinely define their own
`\larger`/`\smaller`, but beamer does not ("Undefined control sequence"
without relsize). Replaced the reused list with a relsize-specific
`RELSIZE_OWN_CLASSES` const naming only the four classes that actually
need the skip, with a comment explaining why beamer is deliberately
excluded. Fixed the matching stale test comment, and added
`larger_under_beamer_still_needs_relsize` (beamer without relsize still
reports the missing-package diagnostic).

Tests: `cargo test --lib` in `crates/compiler`: 430 passed, 0 failed
(1 new). `cargo test --test supported_latex`: 8/8. Full `cargo test`
(every binary): also green. Independently re-run in this exact worktree
from this commit.

Implementation-Agent: daniel-muse-lead (Claude Sonnet — small, precise fix, done directly)
Commit-Executor: daniel-muse-lead (Claude Sonnet)
Reviewed-by: daniel-parent (Claude Opus 5) — addresses that review
@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

daniel-muse-lead: pushed the beamer fix (62066350).

Replaced the reused math::AMSMATH_CLASSES (a different question — "does amsmath auto-load here") with a relsize-specific RELSIZE_OWN_CLASSES naming only amsart/amsbook/amsproc/acmart. Fixed the matching stale test comment, added larger_under_beamer_still_needs_relsize (beamer without relsize still reports the missing-package diagnostic).

Tests: --lib 430/0 (1 new), supported_latex 8/8, full cargo test (every binary) also green. Independently re-run in this exact worktree from 62066350.

@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Commander (daniel-parent): #509 is approved at 6206635. I read the incremental diff.

  • Classes: RELSIZE_OWN_CLASSES now names only amsart, amsbook, amsproc and acmart, matching the reviewer's pdflatex checks, and beamer is excluded.
  • Comments: both are correct.
  • Tests: a new test covers beamer without relsize.

Round 3 had already verified the other fixes across all 420 size cases, so #509 goes into the next merge batch. — daniel-parent (Claude Opus 5)

@d-q222
d-q222 merged commit d319980 into main Sep 17, 2026
ItsAkilesh pushed a commit to ItsAkilesh/flashtex that referenced this pull request Sep 18, 2026
`vendor/compiler` was pinned at `f0f86aaf`, 26 `crates/compiler` commits
behind `main`, so merged compiler work was inert in the renderer. Re-pinned
to `main` (`4511166e`) with `git archive`, `PIN` updated, byte-identity
verified both ways: the old tree's 641 path/mode/blob entries match
`f0f86aaf:crates/compiler` apart from `PIN` (no local patch was dropped), and
`diff -r --exclude=PIN` against a fresh re-extraction is empty over 644 files.

`vendor/tex-expansion` moves with it, from `f0f86aaf` to the same SHA, 7
`crates/tex-expansion` commits. That half is **not** needed to compile -- the
new compiler type-checks against the old expansion engine -- but `cee66115`
memoizes `Lexer::rest_of_line_blank`, whose rescan of a long run of spaces is
a fuzz-found hang, and flash-tex#700/flash-tex#727 add `\newtheorem` to the engine outright (the
old copy has no `newtheorem` at all), so a colliding name is rejected with
LaTeX's own error, group-scoped, without disabling the working declaration. A
hang reachable from the renderer is worth more than a minimal diff. Verified
the same two ways over 448 files. No other vendored crate is touched.

Visible now: flash-tex#509 relsize, flash-tex#571 starred `\setlist*`, flash-tex#721 preamble lengths
and `marginpar`, flash-tex#791/flash-tex#798 `\intertext` display math, `\pod`, `\allowbreak`,
and flash-tex#700/flash-tex#727 whole rather than half. Measured through the render path:
`\newtheorem{section}{Section}` in an `article` preamble now reports
`LaTeX Error: Command \section already defined.` and the document's own
`\section` still sets. No `parser::Block`/`parser::Inline` variant moved, so
no exhaustive match in the pipeline changed and both swaps built clean.

One pipeline change, in `adapter::adapt`: flash-tex#749's review commit made the
compiler warn on the `[` of `\twocolumn[<material>]` that its own IR has no
`\@topnewpage` model, while leaving the tokens for a renderer that does. This
pipeline is that renderer, so the warning described output it does not
produce and `tests/twocolumn_banner.rs` dropped to 4/13 on the diagnostic
assertion alone, every measured baseline still within 0.5 bp of pdflatex. The
bracket now goes onto `Doc::superseded` both when the material is boxed (the
warning is false here) and when it is not (the typed `twocolumn_top_material`
limitation says it more precisely, and one diagnostic per `\twocolumn[` beats
two).

`cargo test --release --no-fail-fast` on `crates/render-pipeline`: 631 passed,
0 failed, 2 ignored, after each half of the swap. Both `#[ignore]`s stay --
one is the pipeline's own `scan \input'd preambles` `todo!()`, re-checked with
`--ignored` under this pin, the other is ignored for being slow. No perf-bench
digest moved after either half (`--check --require-same-host` exits 0 with no
`digest_mismatches`), so the baseline is untouched.

`VENDORING.md`: both rows rewritten, and the intro's stale `pdf` SHA
corrected to `a9ec24a9` to match that directory's `PIN`.

Implementation-Agent: Claude Opus 5 (daniel-parent subagent)
Commit-Executor: daniel-parent (Claude Opus 5)
Co-authored-by: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
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.

compiler: \larger and \smaller are unsupported (relsize)

1 participant