diff --git a/crates/texrra-tex-core/src/math.rs b/crates/texrra-tex-core/src/math.rs index 72fedf1..e512446 100755 --- a/crates/texrra-tex-core/src/math.rs +++ b/crates/texrra-tex-core/src/math.rs @@ -678,14 +678,14 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) { (after + 1).min(chars.len()), ) } - "overset" | "underset" => { + "overset" | "underset" | "stackrel" => { let (top, after) = parse_atom(chars, next); let (base, after) = parse_atom(chars, after); ( MathAtom::Stack { top: Box::new(top), base: Box::new(base), - above: command == "overset", + above: command != "underset", }, after, ) @@ -999,6 +999,14 @@ mod tests { assert!(tall.height > plain.height); assert!(tall.width > plain.width); } + + #[test] + fn stackrel_places_its_first_argument_above_the_relation() { + let font = Cmr10Metrics::default(); + let plain = layout_math(&parse_math("="), &font); + let stacked = layout_math(&parse_math(r"\stackrel{def}{=}"), &font); + assert!(stacked.height > plain.height); + } #[test] fn overset_and_underset_stack_their_arguments() { let font = Cmr10Metrics::default(); diff --git a/docs/TEX_CORE.md b/docs/TEX_CORE.md index 03f6b07..07d9c2c 100755 --- a/docs/TEX_CORE.md +++ b/docs/TEX_CORE.md @@ -212,3 +212,5 @@ for a later overlaid slash. `Unit::vskip(id, height)` adds a vertical glue item to the page list. `Unit::penalty(id, value)` adds a vertical penalty; values <= -10000 force a page break. + +`\stackrel{top}{base}` shares the `Stack` layout with `\overset`.