diff --git a/commands.md b/commands.md index c2e2d6e..00a9ef5 100644 --- a/commands.md +++ b/commands.md @@ -57,6 +57,11 @@ * `\widehat` * `\overline` * `\overrightarrow` +* `\overleftarrow` +* `\overleftrightarrow` +* `\underrightarrow` +* `\underleftarrow` +* `\underleftrightarrow` ## Matrices diff --git a/src/accent.satyh b/src/accent.satyh index a5dd2d9..4a0b23a 100644 --- a/src/accent.satyh +++ b/src/accent.satyh @@ -23,6 +23,11 @@ module AZMathAccent : sig direct \widehat : [float?; math;] math-cmd direct \overline: [math;] math-cmd direct \overrightarrow: [math;] math-cmd + direct \overleftarrow: [math;] math-cmd + direct \overleftrightarrow: [math;] math-cmd + direct \underrightarrow: [math;] math-cmd + direct \underleftarrow: [math;] math-cmd + direct \underleftrightarrow: [math;] math-cmd end = struct @@ -122,8 +127,39 @@ end = struct in text-in-math MathOrd embedf + let path-arrowline x-start x-end = Gr.line (x-start, 0pt) (x-end, 0pt) + let path-leftarrowhead x-start wid-arrowhead = + start-path (x-start +' 2.5pt, wid-arrowhead) + |> bezier-to (x-start +' 2.0pt, wid-arrowhead *' 0.5) (x-start +' 1.5pt, wid-arrowhead *' 0.167) (x-start, 0pt) + |> bezier-to (x-start +' 1.5pt, 0pt -' wid-arrowhead *' 0.167) (x-start +' 2.0pt, 0pt -' wid-arrowhead *' 0.5) (x-start +' 2.5pt, 0pt -' wid-arrowhead) + |> terminate-path + let path-rightarrowhead x-end wid-arrowhead = + start-path (x-end -' 2.5pt, wid-arrowhead) + |> bezier-to (x-end -' 2.0pt, wid-arrowhead *' 0.5) (x-end -' 1.5pt, wid-arrowhead *' 0.167) (x-end, 0pt) + |> bezier-to (x-end -' 1.5pt, 0pt -' wid-arrowhead *' 0.167) (x-end -' 2.0pt, 0pt -' wid-arrowhead *' 0.5) (x-end -' 2.5pt, 0pt -' wid-arrowhead) + |> terminate-path + let-math \overrightarrow m = + let embedf ctx = + let fsize = get-font-size ctx in + let margin = fsize *' 0.25 in + let wid-arrowhead = 3pt in + let deco (x, y) wid ht dp = + let text-color = get-text-color ctx in + let ht-base = y +' ht -' wid-arrowhead in + let x-start = 0pt in + let x-end = wid in + [ + stroke 0.5pt text-color (path-arrowline x-start x-end |> shift-path (x, ht-base)); + stroke 0.5pt text-color (path-rightarrowhead x-end wid-arrowhead |> shift-path (x, ht-base)); + ] + in + inline-frame-outer (0pt, 0pt, margin +' wid-arrowhead, 0pt) deco (embed-math ctx m) + in + text-in-math MathOrd embedf + + let-math \overleftarrow m = let embedf ctx = let fsize = get-font-size ctx in let margin = fsize *' 0.25 in @@ -132,26 +168,96 @@ end = struct let deco (x, y) wid ht dp = let text-color = get-text-color ctx in let ht-base = y +' ht -' wid-arrowhead in + let x-start = 0pt in + let x-end = wid in + [ + stroke 0.5pt text-color (path-arrowline x-start x-end |> shift-path (x, ht-base)); + stroke 0.5pt text-color (path-leftarrowhead x-start wid-arrowhead |> shift-path (x, ht-base)); + ] + in + inline-frame-outer (0pt, 0pt, margin +' wid-arrowhead, 0pt) deco (embed-math ctx m) + in + text-in-math MathOrd embedf + + let-math \overleftrightarrow m = + let embedf ctx = + let fsize = get-font-size ctx in + let margin = fsize *' 0.25 in + let wid-arrowhead = 3pt in + let deco (x, y) wid ht dp = + let text-color = get-text-color ctx in + let ht-base = y +' ht -' wid-arrowhead in let x-start = 0pt in - let x-end = wid -' 1pt in + let x-end = wid in + [ + stroke 0.5pt text-color (path-arrowline x-start x-end |> shift-path (x, ht-base)); + stroke 0.5pt text-color (path-leftarrowhead x-start wid-arrowhead |> shift-path (x, ht-base)); + stroke 0.5pt text-color (path-rightarrowhead x-end wid-arrowhead |> shift-path (x, ht-base)); + ] + in + inline-frame-outer (0pt, 0pt, margin +' wid-arrowhead, 0pt) deco (embed-math ctx m) + in + text-in-math MathOrd embedf - let path-line = Gr.line (x-start, 0pt) (x-end, 0pt) in + let-math \underrightarrow m = + let embedf ctx = + let fsize = get-font-size ctx in + let margin = fsize *' 0.25 in + let wid-arrowhead = 3pt in - let path-arrowhead = - start-path (x-end -' 2.5pt, wid-arrowhead) - |> bezier-to (x-end -' 2.0pt, 1.5pt) (x-end -' 1.5pt, 0.5pt) (x-end, 0pt) - |> bezier-to (x-end -' 1.5pt, -0.5pt) (x-end -' 2.0pt, -1.5pt) (x-end -' 2.5pt, (0pt -' wid-arrowhead)) - |> terminate-path - in + let deco (x, y) wid ht dp = + let text-color = get-text-color ctx in + let ht-base = y -' wid-arrowhead in + let x-start = 0pt in + let x-end = wid in + [ + stroke 0.5pt text-color (path-arrowline x-start x-end |> shift-path (x, ht-base)); + stroke 0.5pt text-color (path-rightarrowhead x-end wid-arrowhead |> shift-path (x, ht-base)); + ] + in + inline-frame-outer (0pt, 0pt, margin +' wid-arrowhead, 0pt) deco (embed-math ctx m) + in + text-in-math MathOrd embedf + + let-math \underleftarrow m = + let embedf ctx = + let fsize = get-font-size ctx in + let margin = fsize *' 0.25 in + let wid-arrowhead = 3pt in + + let deco (x, y) wid ht dp = + let text-color = get-text-color ctx in + let ht-base = y -' wid-arrowhead in + let x-start = 0pt in + let x-end = wid in [ - stroke 0.5pt text-color (path-line |> shift-path (x, ht-base)); - stroke 0.5pt text-color (path-arrowhead |> shift-path (x, ht-base)); + stroke 0.5pt text-color (path-arrowline x-start x-end |> shift-path (x, ht-base)); + stroke 0.5pt text-color (path-leftarrowhead x-start wid-arrowhead |> shift-path (x, ht-base)); ] in inline-frame-outer (0pt, 0pt, margin +' wid-arrowhead, 0pt) deco (embed-math ctx m) in text-in-math MathOrd embedf + let-math \underleftrightarrow m = + let embedf ctx = + let fsize = get-font-size ctx in + let margin = fsize *' 0.25 in + let wid-arrowhead = 3pt in + let deco (x, y) wid ht dp = + let text-color = get-text-color ctx in + let ht-base = y -' wid-arrowhead in + let x-start = 0pt in + let x-end = wid in + [ + stroke 0.5pt text-color (path-arrowline x-start x-end |> shift-path (x, ht-base)); + stroke 0.5pt text-color (path-leftarrowhead x-start wid-arrowhead |> shift-path (x, ht-base)); + stroke 0.5pt text-color (path-rightarrowhead x-end wid-arrowhead |> shift-path (x, ht-base)); + ] + in + inline-frame-outer (0pt, 0pt, margin +' wid-arrowhead, 0pt) deco (embed-math ctx m) + in + text-in-math MathOrd embedf end