diff --git a/crates/texrra-tex-core/src/math.rs b/crates/texrra-tex-core/src/math.rs index 947eb42..08acbd4 100755 --- a/crates/texrra-tex-core/src/math.rs +++ b/crates/texrra-tex-core/src/math.rs @@ -46,6 +46,7 @@ pub enum MathAtom { horizontal: bool, vertical: bool, }, + Strut, Limits { base: Box, sub: Option>, @@ -263,6 +264,11 @@ pub fn layout_math(atom: &MathAtom, font: &Cmr10Metrics) -> MathBox { depth: if *bottom { 0 } else { body.depth }, } } + MathAtom::Strut => MathBox { + width: 0, + height: 7 * 65_536, + depth: 2 * 65_536, + }, MathAtom::Phantom { body, horizontal, @@ -630,6 +636,7 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) { after, ) } + "mathstrut" => (MathAtom::Strut, next), "phantom" | "hphantom" | "vphantom" => { let (body, after) = parse_atom(chars, next); ( @@ -1002,6 +1009,16 @@ mod tests { assert_eq!(smashed.height, 0); assert_eq!(smashed.depth, 0); } + + #[test] + fn mathstrut_has_zero_width_and_math_height() { + let font = Cmr10Metrics::default(); + let box_ = layout_math(&parse_math(r"\mathstrut"), &font); + assert_eq!(box_.width, 0); + assert_eq!(box_.height, 7 * 65_536); + assert_eq!(box_.depth, 2 * 65_536); + } + #[test] fn phantoms_keep_only_selected_dimensions() { let font = Cmr10Metrics::default(); diff --git a/docs/TEX_CORE.md b/docs/TEX_CORE.md index a645642..f977181 100755 --- a/docs/TEX_CORE.md +++ b/docs/TEX_CORE.md @@ -243,3 +243,5 @@ v1 remains the production renderer; the route-D core is additive and tested inde `Unit::mark(id, class, text)` and `Unit::float(id, placement, width, height)` are convenience constructors for M2 page items. `\mathop` uses the Op spacing class (3mu against ordinary atoms). + +`\mathstrut` is a zero-width strut with 7pt height and 2pt depth.