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();