diff --git a/crates/texrra-tex-core/src/math.rs b/crates/texrra-tex-core/src/math.rs index e512446..296beeb 100755 --- a/crates/texrra-tex-core/src/math.rs +++ b/crates/texrra-tex-core/src/math.rs @@ -730,6 +730,21 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) { after, ) } + "overrightarrow" | "overleftarrow" => { + let (base, after) = parse_atom(chars, next); + let accent = if command == "overrightarrow" { + '\u{20D7}' + } else { + '\u{20D6}' + }; + ( + MathAtom::Accent { + accent, + base: Box::new(base), + }, + after, + ) + } "vec" => { let (base, after) = parse_atom(chars, next); ( @@ -1000,6 +1015,20 @@ mod tests { assert!(tall.width > plain.width); } + #[test] + fn overrightarrow_uses_the_arrow_accent() { + let parsed = parse_math(r"\overrightarrow{AB}"); + let MathAtom::Row(atoms) = parsed else { + panic!("expected row") + }; + assert!(matches!( + &atoms[0], + MathAtom::Accent { + accent: '\u{20D7}', + .. + } + )); + } #[test] fn stackrel_places_its_first_argument_above_the_relation() { let font = Cmr10Metrics::default(); diff --git a/docs/TEX_CORE.md b/docs/TEX_CORE.md index 07d9c2c..0789e82 100755 --- a/docs/TEX_CORE.md +++ b/docs/TEX_CORE.md @@ -214,3 +214,5 @@ for a later overlaid slash. `Unit::penalty(id, value)` adds a vertical penalty; values <= -10000 force a page break. `\stackrel{top}{base}` shares the `Stack` layout with `\overset`. + +`\overrightarrow`/`\overleftarrow` parse as arrow accents (U+20D7/U+20D6).