mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-13 06:58:40 +00:00
Support \widecheck (#1406)
Fixes #1221. Implemented as an upside-down version of `\widehat`.
This commit is contained in:
@@ -209,7 +209,7 @@ defineFunction({
|
||||
type: "accent",
|
||||
names: [
|
||||
"\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve",
|
||||
"\\check", "\\hat", "\\vec", "\\dot", "\\mathring",
|
||||
"\\check", "\\hat", "\\vec", "\\dot", "\\mathring", "\\widecheck",
|
||||
"\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow",
|
||||
"\\Overrightarrow", "\\overleftrightarrow", "\\overgroup",
|
||||
"\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon",
|
||||
@@ -223,7 +223,8 @@ defineFunction({
|
||||
const isStretchy = !NON_STRETCHY_ACCENT_REGEX.test(context.funcName);
|
||||
const isShifty = !isStretchy ||
|
||||
context.funcName === "\\widehat" ||
|
||||
context.funcName === "\\widetilde";
|
||||
context.funcName === "\\widetilde" ||
|
||||
context.funcName === "\\widecheck";
|
||||
|
||||
return new ParseNode("accent", {
|
||||
type: "accent",
|
||||
|
@@ -16,6 +16,7 @@ import type {DomSpan, SvgSpan} from "./domTree";
|
||||
|
||||
const stretchyCodePoint: {[string]: string} = {
|
||||
widehat: "^",
|
||||
widecheck: "ˇ",
|
||||
widetilde: "~",
|
||||
utilde: "~",
|
||||
overleftarrow: "\u2190",
|
||||
@@ -180,7 +181,8 @@ const svgSpan = function(
|
||||
} {
|
||||
let viewBoxWidth = 400000; // default
|
||||
const label = group.value.label.substr(1);
|
||||
if (utils.contains(["widehat", "widetilde", "utilde"], label)) {
|
||||
if (utils.contains(["widehat", "widecheck", "widetilde", "utilde"],
|
||||
label)) {
|
||||
// Each type in the `if` statement corresponds to one of the ParseNode
|
||||
// types below. This narrowing is required to access `grp.value.base`.
|
||||
// $FlowFixMe
|
||||
@@ -193,18 +195,24 @@ const svgSpan = function(
|
||||
let height;
|
||||
|
||||
if (numChars > 5) {
|
||||
viewBoxHeight = (label === "widehat" ? 420 : 312);
|
||||
viewBoxWidth = (label === "widehat" ? 2364 : 2340);
|
||||
// Next get the span height, in 1000 ems
|
||||
height = (label === "widehat" ? 0.42 : 0.34);
|
||||
pathName = (label === "widehat" ? "widehat" : "tilde") + "4";
|
||||
if (label === "widehat" || label === "widecheck") {
|
||||
viewBoxHeight = 420;
|
||||
viewBoxWidth = 2364;
|
||||
height = 0.42;
|
||||
pathName = label + "4";
|
||||
} else {
|
||||
viewBoxHeight = 312;
|
||||
viewBoxWidth = 2340;
|
||||
height = 0.34;
|
||||
pathName = "tilde4";
|
||||
}
|
||||
} else {
|
||||
const imgIndex = [1, 1, 2, 2, 3, 3][numChars];
|
||||
if (label === "widehat") {
|
||||
if (label === "widehat" || label === "widecheck") {
|
||||
viewBoxWidth = [0, 1062, 2364, 2364, 2364][imgIndex];
|
||||
viewBoxHeight = [0, 239, 300, 360, 420][imgIndex];
|
||||
height = [0, 0.24, 0.3, 0.3, 0.36, 0.42][imgIndex];
|
||||
pathName = "widehat" + imgIndex;
|
||||
pathName = label + imgIndex;
|
||||
} else {
|
||||
viewBoxWidth = [0, 600, 1033, 2339, 2340][imgIndex];
|
||||
viewBoxHeight = [0, 260, 286, 306, 312][imgIndex];
|
||||
|
@@ -281,6 +281,19 @@ c-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z`,
|
||||
widehat4: `M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10
|
||||
-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`,
|
||||
|
||||
// widecheck paths are all inverted versions of widehat
|
||||
widecheck1: `M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,
|
||||
-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z`,
|
||||
|
||||
widecheck2: `M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
|
||||
-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`,
|
||||
|
||||
widecheck3: `M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
|
||||
-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`,
|
||||
|
||||
widecheck4: `M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
|
||||
-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`,
|
||||
|
||||
// baraboveleftarrow is from glyph U+21C4 in font KaTeX AMS Regular
|
||||
baraboveleftarrow: `M1 500c30.67-18 59-41.833 85-71.5s45-61.17 57-94.5h23
|
||||
c15.33 0 23 .33 23 1 0 .67-5.33 12.67-16 36-16.67 34.67-39 67.33-67 98l-10 11
|
||||
|
Reference in New Issue
Block a user