Add \underline support (#456)
 Fixes #209.
This commit is contained in:
parent
a33fa4fd64
commit
965b8a6164
|
@ -51,6 +51,7 @@ var groupToType = {
|
||||||
op: "mop",
|
op: "mop",
|
||||||
katex: "mord",
|
katex: "mord",
|
||||||
overline: "mord",
|
overline: "mord",
|
||||||
|
underline: "mord",
|
||||||
rule: "mord",
|
rule: "mord",
|
||||||
leftright: "minner",
|
leftright: "minner",
|
||||||
sqrt: "mord",
|
sqrt: "mord",
|
||||||
|
@ -928,6 +929,32 @@ groupTypes.overline = function(group, options, prev) {
|
||||||
return makeSpan(["overline", "mord"], [vlist], options.getColor());
|
return makeSpan(["overline", "mord"], [vlist], options.getColor());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
groupTypes.underline = function(group, options, prev) {
|
||||||
|
// Underlines are handled in the TeXbook pg 443, Rule 10.
|
||||||
|
|
||||||
|
// Build the inner group.
|
||||||
|
var innerGroup = buildGroup(group.value.body, options);
|
||||||
|
|
||||||
|
var ruleWidth = fontMetrics.metrics.defaultRuleThickness /
|
||||||
|
options.style.sizeMultiplier;
|
||||||
|
|
||||||
|
// Create the line above the body
|
||||||
|
var line = makeSpan(
|
||||||
|
[options.style.reset(), Style.TEXT.cls(), "underline-line"]);
|
||||||
|
line.height = ruleWidth;
|
||||||
|
line.maxFontSize = 1.0;
|
||||||
|
|
||||||
|
// Generate the vlist, with the appropriate kerns
|
||||||
|
var vlist = buildCommon.makeVList([
|
||||||
|
{type: "kern", size: ruleWidth},
|
||||||
|
{type: "elem", elem: line},
|
||||||
|
{type: "kern", size: 3 * ruleWidth},
|
||||||
|
{type: "elem", elem: innerGroup},
|
||||||
|
], "top", innerGroup.height, options);
|
||||||
|
|
||||||
|
return makeSpan(["underline", "mord"], [vlist], options.getColor());
|
||||||
|
};
|
||||||
|
|
||||||
groupTypes.sqrt = function(group, options, prev) {
|
groupTypes.sqrt = function(group, options, prev) {
|
||||||
// Square roots are handled in the TeXbook pg. 443, Rule 11.
|
// Square roots are handled in the TeXbook pg. 443, Rule 11.
|
||||||
|
|
||||||
|
|
|
@ -422,6 +422,20 @@ groupTypes.overline = function(group, options) {
|
||||||
return node;
|
return node;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
groupTypes.underline = function(group, options) {
|
||||||
|
var operator = new mathMLTree.MathNode(
|
||||||
|
"mo", [new mathMLTree.TextNode("\u203e")]);
|
||||||
|
operator.setAttribute("stretchy", "true");
|
||||||
|
|
||||||
|
var node = new mathMLTree.MathNode(
|
||||||
|
"munder",
|
||||||
|
[buildGroup(group.value.body, options),
|
||||||
|
operator]);
|
||||||
|
node.setAttribute("accentunder", "true");
|
||||||
|
|
||||||
|
return node;
|
||||||
|
};
|
||||||
|
|
||||||
groupTypes.rule = function(group) {
|
groupTypes.rule = function(group) {
|
||||||
// TODO(emily): Figure out if there's an actual way to draw black boxes
|
// TODO(emily): Figure out if there's an actual way to draw black boxes
|
||||||
// in MathML.
|
// in MathML.
|
||||||
|
|
|
@ -170,6 +170,17 @@ defineFunction("\\overline", {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// An underline
|
||||||
|
defineFunction("\\underline", {
|
||||||
|
numArgs: 1,
|
||||||
|
}, function(context, args) {
|
||||||
|
var body = args[0];
|
||||||
|
return {
|
||||||
|
type: "underline",
|
||||||
|
body: body,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
// A box of the width and height
|
// A box of the width and height
|
||||||
defineFunction("\\rule", {
|
defineFunction("\\rule", {
|
||||||
numArgs: 2,
|
numArgs: 2,
|
||||||
|
|
|
@ -352,25 +352,23 @@
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.overline {
|
.overline .overline-line,
|
||||||
|
.underline .underline-line {
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
.overline-line {
|
&:before {
|
||||||
width: 100%;
|
border-bottom-style: solid;
|
||||||
|
border-bottom-width: 1px;
|
||||||
|
content: "";
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
&:before {
|
&:after {
|
||||||
border-bottom-style: solid;
|
border-bottom-style: solid;
|
||||||
border-bottom-width: 1px;
|
border-bottom-width: 0.04em;
|
||||||
content: "";
|
content: "";
|
||||||
display: block;
|
display: block;
|
||||||
}
|
margin-top: -1px;
|
||||||
|
|
||||||
&:after {
|
|
||||||
border-bottom-style: solid;
|
|
||||||
border-bottom-width: 0.04em;
|
|
||||||
content: "";
|
|
||||||
display: block;
|
|
||||||
margin-top: -1px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
BIN
test/screenshotter/images/OverUnderline-chrome.png
Normal file
BIN
test/screenshotter/images/OverUnderline-chrome.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
test/screenshotter/images/OverUnderline-firefox.png
Normal file
BIN
test/screenshotter/images/OverUnderline-firefox.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
Binary file not shown.
Before Width: | Height: | Size: 11 KiB |
Binary file not shown.
Before Width: | Height: | Size: 9.3 KiB |
|
@ -85,7 +85,7 @@ NullDelimiterInteraction: a \bigl. + 2 \quad \left. + a \right)
|
||||||
OpLimits: |
|
OpLimits: |
|
||||||
{\sin_2^2 \lim_2^2 \int_2^2 \sum_2^2}
|
{\sin_2^2 \lim_2^2 \int_2^2 \sum_2^2}
|
||||||
{\displaystyle \lim_2^2 \int_2^2 \intop_2^2 \sum_2^2}
|
{\displaystyle \lim_2^2 \int_2^2 \intop_2^2 \sum_2^2}
|
||||||
Overline: \overline{x}\overline{x}\overline{x^{x^{x^x}}} \blue{\overline{y}}
|
OverUnderline: x\underline{x}\underline{\underline{x}}\underline{x_{x_{x_x}}}\underline{x^{x^{x^x}}}\overline{x}\overline{x}\overline{x^{x^{x^x}}} \blue{\overline{\underline{x}}\underline{\overline{x}}}
|
||||||
Phantom: \dfrac{1+\phantom{x^{\blue{2}}} = x}{1+x^{\blue{2}} = x}
|
Phantom: \dfrac{1+\phantom{x^{\blue{2}}} = x}{1+x^{\blue{2}} = x}
|
||||||
PrimeSpacing: f'+f_2'+f^{f'}
|
PrimeSpacing: f'+f_2'+f^{f'}
|
||||||
RlapBug: \frac{\rlap{x}}{2}
|
RlapBug: \frac{\rlap{x}}{2}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user