From c7b0124369e1ec1b15b5aa95322fe06cdde0f082 Mon Sep 17 00:00:00 2001 From: GloamXun Date: Tue, 20 Oct 2026 19:21:15 +0800 Subject: [PATCH] Let mathop take limits below its body --- crates/texrra-tex-core/src/math.rs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/crates/texrra-tex-core/src/math.rs b/crates/texrra-tex-core/src/math.rs index bd56c05..2a53efe 100755 --- a/crates/texrra-tex-core/src/math.rs +++ b/crates/texrra-tex-core/src/math.rs @@ -745,13 +745,15 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) { "mathinner" => MathClass::Inner, _ => MathClass::Ordinary, }; - ( - MathAtom::Classed { - class, - body: Box::new(body), - }, - after, - ) + let atom = MathAtom::Classed { + class, + body: Box::new(body), + }; + if command == "mathop" { + parse_limits(chars, after, atom) + } else { + (atom, after) + } } "big" | "bigl" | "bigr" | "Big" | "Bigl" | "Bigr" | "bigg" | "biggl" | "biggr" | "Bigg" | "Biggl" | "Biggr" => { @@ -1396,6 +1398,13 @@ mod tests { )); } + #[test] + fn mathop_takes_limits_below() { + let font = Cmr10Metrics::default(); + let plain = layout_math(&parse_math(r"\mathop{argmax}"), &font); + let limited = layout_math(&parse_math(r"\mathop{argmax}_{x}"), &font); + assert!(limited.depth > plain.depth); + } #[test] fn starred_operatorname_takes_limits_below() { let font = Cmr10Metrics::default();