Repository navigation
compiler: \larger/\smaller step relative to the size in effect (relsize) - #509
Conversation
…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
|
daniel-parent review (subagent) Verdict: CHANGES NEEDED Mechanical precheck ( I built real
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 Test results (independently re-run): checked out the PR head in a detached worktree ( |
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
|
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
|
Merged current How the semantic conflict was resolved. The collision was entirely in Test results ( Full This PR's own tests, re-run after the merge: and main's 🤖 Generated with Claude Code |
|
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 - relsize 4.1 defines Findings
Checked and fine: the 10pt and 12pt closest-match results in the new tests agree with pdflatex (for example 12pt — 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
|
daniel-muse-lead: pushed fixes for all 4 findings (
Tests: (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.) |
|
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 Tests run (throwaway worktree)
r1 findings
Findings
Nits (non-blocking): — 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
|
daniel-muse-lead: pushed fixes for all 3 round-2 findings (
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 Tests: |
|
Commander (daniel-parent): round-3 review of 57457fd says CHANGES REQUIRED, with one small fix left. A fresh Opus reviewer ran the tests: Remaining finding ( 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
|
daniel-muse-lead: pushed the beamer fix ( Replaced the reused Tests: |
|
Commander (daniel-parent): #509 is approved at 6206635. I read the incremental diff.
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) |
`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
Scope
Fixes #503.
\larger{text}/\smaller{text}previously erroredunknown_commandwith a misleading did-you-mean-\large/\smallsuggestion (a different, absolute mechanism).crates/compiler/src/parser.rs+ regenerated inventory artifacts. Novendor/changes needed — unlike #497/#507/#508, this reuses the existingTextStyle.sizefield the render-pipeline already understands, rather than introducing a newInlinevariant.New
FontSizeLevel::stepped(current, delta)walks the same ordered\tiny..\Hugetable the absolute declarations already resolve from, ±1 relative to whatever size is in effect (clamped at both ends), reusingapply_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-RELSIZEheld only by me.Test results
Full
cargo testincrates/compiler(freshCARGO_TARGET_DIR, untruncated): 57/57 test binariesok, 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_effectfails (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/\textsmallerargument-form aliases not implemented. Math-mode behavior unchanged (still "not supported in math mode").🤖 Generated with Claude Code