Support stretchy wide elements. (#670)

This commit is contained in:
Ron Kok
2017-06-15 20:47:51 -07:00
committed by Kevin Barabash
parent eaa7f3a17d
commit eff7653c51
57 changed files with 1634 additions and 42 deletions

View File

@@ -634,19 +634,99 @@ defineFunction([
defineFunction([
"\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve",
"\\check", "\\hat", "\\vec", "\\dot",
// We don't support expanding accents yet
// "\\widetilde", "\\widehat"
"\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow",
"\\Overrightarrow", "\\overleftrightarrow", "\\overgroup",
"\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon",
], {
numArgs: 1,
}, function(context, args) {
const base = args[0];
const isStretchy = !utils.contains([
"\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve",
"\\check", "\\hat", "\\vec", "\\dot",
], context.funcName);
const isShifty = !isStretchy || utils.contains([
"\\widehat", "\\widetilde",
], context.funcName);
return {
type: "accent",
label: context.funcName,
isStretchy: isStretchy,
isShifty: isShifty,
value: ordargument(base),
base: base,
};
});
// Horizontal stretchy braces
defineFunction([
"\\overbrace", "\\underbrace",
], {
numArgs: 1,
}, function(context, args) {
const base = args[0];
return {
type: "accent",
accent: context.funcName,
type: "horizBrace",
label: context.funcName,
isOver: /^\\over/.test(context.funcName),
base: base,
};
});
// Stretchy accents under the body
defineFunction([
"\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow",
"\\undergroup", "\\underlinesegment", "\\undertilde",
], {
numArgs: 1,
}, function(context, args) {
const body = args[0];
return {
type: "accentUnder",
label: context.funcName,
value: ordargument(body),
body: body,
};
});
// Stretchy arrows with an optional argument
defineFunction([
"\\xleftarrow", "\\xrightarrow", "\\xLeftarrow", "\\xRightarrow",
"\\xleftrightarrow", "\\xLeftrightarrow", "\\xhookleftarrow",
"\\xhookrightarrow", "\\xmapsto", "\\xrightharpoondown",
"\\xrightharpoonup", "\\xleftharpoondown", "\\xleftharpoonup",
"\\xrightleftharpoons", "\\xleftrightharpoons", "\\xLongequal",
"\\xtwoheadrightarrow", "\\xtwoheadleftarrow", "\\xLongequal",
"\\xtofrom",
], {
numArgs: 1,
numOptionalArgs: 1,
}, function(context, args) {
const below = args[0];
const body = args[1];
return {
type: "xArrow", // x for extensible
label: context.funcName,
body: body,
below: below,
};
});
// enclose
defineFunction(["\\cancel", "\\bcancel", "\\xcancel", "\\sout", "\\fbox"], {
numArgs: 1,
}, function(context, args) {
const body = args[0];
return {
type: "enclose",
label: context.funcName,
body: body,
};
});
// Infix generalized fractions
defineFunction(["\\over", "\\choose", "\\atop"], {
numArgs: 0,