diff --git a/crates/texrra-tex-core/src/math.rs b/crates/texrra-tex-core/src/math.rs index deca5c0..0465b25 100755 --- a/crates/texrra-tex-core/src/math.rs +++ b/crates/texrra-tex-core/src/math.rs @@ -588,7 +588,7 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) { } parse_atom(chars, after) } - "frac" => { + "frac" | "tfrac" | "dfrac" | "cfrac" => { let (numerator, after) = parse_atom(chars, next); let (denominator, after) = parse_atom(chars, after); (MathAtom::fraction(numerator, denominator), after) @@ -1247,6 +1247,17 @@ mod tests { assert_eq!(under.height, plain.height); } + #[test] + fn fraction_style_aliases_match_frac() { + let font = Cmr10Metrics::default(); + let plain = layout_math(&parse_math(r"\frac{a}{b}"), &font); + for command in ["tfrac", "dfrac", "cfrac"] { + let source = format!(r"\{command}{{a}}{{b}}"); + let boxed = layout_math(&parse_math(&source), &font); + assert_eq!(plain.width, boxed.width); + assert_eq!(plain.height, boxed.height); + } + } #[test] fn math_spacing_commands_have_expected_widths() { let font = Cmr10Metrics::default();