Skip to content

compiler: proof/theorem environments now inherit the enclosing size group (fixes #701) - #718

Merged
d-q222 merged 1 commit into
mainfrom
agent/daniel-muse-lead/size-group-env
Sep 17, 2026
Merged

d-q222 merged 1 commit into
mainfrom
agent/daniel-muse-lead/size-group-env

Conversation

@d-q222

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

Copy link
Copy Markdown
Contributor

Scope

Fixes #701: a size group (\large, etc.) around \begin{proof}...\end{proof}
or a \newtheorem-declared environment was being dropped entirely — both the
head ("Proof."/"Theorem 1.") and body rendered at \normalsize regardless of
the enclosing size. crates/compiler/ only (2 files, +234/-6); crates/render-pipeline/
untouched.

Scoped as requested before fixing: itemize, quote, and center all
already correctly carry \large into their contents (confirmed via a fresh
flashtex-cli build's --v2 display-list JSON font references, off current
main). Only amsthm/\newtheorem-style theorem environments were affected —
verified against both proof and a plain \newtheorem-declared theorem.
Not a general "size register isn't carried into environment bodies" bug.

Root cause: begin_proof and begin_theorem (crates/compiler/src/parser.rs)
unconditionally rebuilt self.style/head-and-body text styles from
TextStyle::default() / TheoremStyle::head_style()/body_style()
(context-free style definitions in theorems.rs), discarding whatever
size: Option<FontSizeLevel> was in effect on entry. Fix: capture
let ambient_size = self.style.size at entry to each function and merge it
into the head/number/note/body styles (TextStyle { size: ambient_size, ..X })
rather than changing TheoremStyle::head_style()/body_style() themselves
(verified they have no other call sites). The closing "∎" now also uses the
body's current self.style instead of a hardcoded default. The
\thm@notefont note style was confirmed against the real amsthm.sty
source (\fontseries\mddefault\upshape — series/shape only, never resets
size), so it also inherits ambient size like the head.

Overlap check

No overlap: compiler-only, no vendor/ touch, no other open PR touches
begin_proof/begin_theorem/TheoremStyle.

Test results

6 new exact-TextStyle tests in crates/compiler/tests/amsthm.rs: proof
head+body+QED at \large, plain-theorem head+punctuation+body at \large,
note at \large, definition-style at \large, remark-style (italic head,
upright \@upn number, upright body) at \large, and an itemize/quote/center
regression guard confirming they still work under \large.

Independently re-verified by the supervisor (fresh CARGO_TARGET_DIR):

  • cargo test --test amsthm: 25 passed, 0 failed — matches the lane's
    own report exactly.
  • Mutation check (re-run independently, not just quoted from the lane):
    reverted parser.rs to its pre-fix state via git checkout origin/main -- crates/compiler/src/parser.rs, re-ran the suite: exactly 5 tests fail
    (definition_style_preserves_enclosing_size,
    plain_theorem_preserves_enclosing_size_in_head_and_body,
    proof_preserves_enclosing_size_in_head_and_body,
    remark_style_preserves_enclosing_size,
    theorem_note_preserves_enclosing_size), each with the exact dropped-size
    assertion failure (size: None vs expected Some(Large1)). Restored →
    25/25 pass again.
  • Full crates/compiler suite (fresh target dir): all suites green, 0
    failures.

Not done

CLI/--v2-visible confirmation is blocked on the crates/render-pipeline/vendor/compiler
re-pin (that mirror predates this fix and has no ambient_size concept) —
out of scope for this compiler-only slice per the issue's own instruction.
The lane's positive control ({\large\begin{itemize}...} renders at
LMRoman12-Regular through the same CLI binary) confirms the render path
correctly maps Large1→12pt once the compiler emits it; this PR is what
makes proof/theorem emit it. Once the pending vendor re-pin (daniel-parent's
PR #711) lands, flashtex build on the issue's repro should show
LMRoman12-* for the proof/theorem head and body.

🤖 Generated with Claude Code

begin_proof and begin_theorem reset self.style to size-less defaults,
dropping an enclosing size group (e.g. {\large ...}): head, number, note
and body all fell back to normalsize. Capture the ambient size at entry
and merge it into the heading, head/number, note and body styles; the
proof QED symbol now uses the body style. TheoremStyle::head/body_style
stay context-free; unscoped output is unchanged.

Implementation-Agent: muse-spark-1.3-contributor
@d-q222
d-q222 merged commit 344879a into main Sep 17, 2026
21 of 22 checks passed
d-q222 added a commit that referenced this pull request Sep 17, 2026
 #784

All eight independently reviewed APPROVE. Batch verification: compiler
935/0, render-pipeline 487/0, perf-bench 14/0, perf gate OK (270 metrics,
no regression), swift build --build-tests OK, CompletionTests 29/0.

Commit-Executor: daniel-parent
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: a size group around an environment is dropped — {\large\begin{proof}...} sets at \normalsize

1 participant