Ben Alpert 2016-04-10 20:32:24 -07:00
parent a33fa4fd64
commit 965b8a6164
9 changed files with 68 additions and 18 deletions

View File

@ -51,6 +51,7 @@ var groupToType = {
op: "mop",
katex: "mord",
overline: "mord",
underline: "mord",
rule: "mord",
leftright: "minner",
sqrt: "mord",
@ -928,6 +929,32 @@ groupTypes.overline = function(group, options, prev) {
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) {
// Square roots are handled in the TeXbook pg. 443, Rule 11.

View File

@ -422,6 +422,20 @@ groupTypes.overline = function(group, options) {
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) {
// TODO(emily): Figure out if there's an actual way to draw black boxes
// in MathML.

View File

@ -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
defineFunction("\\rule", {
numArgs: 2,

View File

@ -352,25 +352,23 @@
position: relative;
}
.overline {
.overline .overline-line,
.underline .underline-line {
width: 100%;
.overline-line {
width: 100%;
&:before {
border-bottom-style: solid;
border-bottom-width: 1px;
content: "";
display: block;
}
&:before {
border-bottom-style: solid;
border-bottom-width: 1px;
content: "";
display: block;
}
&:after {
border-bottom-style: solid;
border-bottom-width: 0.04em;
content: "";
display: block;
margin-top: -1px;
}
&:after {
border-bottom-style: solid;
border-bottom-width: 0.04em;
content: "";
display: block;
margin-top: -1px;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

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

View File

@ -85,7 +85,7 @@ NullDelimiterInteraction: a \bigl. + 2 \quad \left. + a \right)
OpLimits: |
{\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}
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}
PrimeSpacing: f'+f_2'+f^{f'}
RlapBug: \frac{\rlap{x}}{2}