Support \atop.

Add Jasmine test and update screenshotter test.
This commit is contained in:
Eddie Kohler 2016-11-23 09:28:09 -05:00
parent f8e0c91de4
commit e0407a19a0
5 changed files with 18 additions and 2 deletions

View File

@ -418,6 +418,7 @@ defineFunction("\\mathop", {
defineFunction([ defineFunction([
"\\dfrac", "\\frac", "\\tfrac", "\\dfrac", "\\frac", "\\tfrac",
"\\dbinom", "\\binom", "\\tbinom", "\\dbinom", "\\binom", "\\tbinom",
"\\\\atopfrac", // cant be entered directly
], { ], {
numArgs: 2, numArgs: 2,
greediness: 2, greediness: 2,
@ -435,6 +436,9 @@ defineFunction([
case "\\tfrac": case "\\tfrac":
hasBarLine = true; hasBarLine = true;
break; break;
case "\\\\atopfrac":
hasBarLine = false;
break;
case "\\dbinom": case "\\dbinom":
case "\\binom": case "\\binom":
case "\\tbinom": case "\\tbinom":
@ -571,7 +575,7 @@ defineFunction([
}); });
// Infix generalized fractions // Infix generalized fractions
defineFunction(["\\over", "\\choose"], { defineFunction(["\\over", "\\choose", "\\atop"], {
numArgs: 0, numArgs: 0,
infix: true, infix: true,
}, function(context) { }, function(context) {
@ -583,6 +587,9 @@ defineFunction(["\\over", "\\choose"], {
case "\\choose": case "\\choose":
replaceWith = "\\binom"; replaceWith = "\\binom";
break; break;
case "\\atop":
replaceWith = "\\\\atopfrac";
break;
default: default:
throw new Error("Unrecognized infix genfrac command"); throw new Error("Unrecognized infix genfrac command");
} }

View File

@ -606,6 +606,15 @@ describe("A frac parser", function() {
expect(tfracParse.value.numer).toBeDefined(); expect(tfracParse.value.numer).toBeDefined();
expect(tfracParse.value.denom).toBeDefined(); expect(tfracParse.value.denom).toBeDefined();
}); });
it("should parse atop", function() {
var parse = getParsed("x \\atop y")[0];
expect(parse.type).toEqual("genfrac");
expect(parse.value.numer).toBeDefined();
expect(parse.value.denom).toBeDefined();
expect(parse.value.hasBarLine).toEqual(false);
});
}); });
describe("An over parser", function() { describe("An over parser", function() {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

@ -62,7 +62,7 @@ DisplayStyle: |
{\displaystyle\sqrt{x}}{\sqrt{x}} {\displaystyle\sqrt{x}}{\sqrt{x}}
{\displaystyle \frac12}{\frac12}{\displaystyle x^1_2}{x^1_2} {\displaystyle \frac12}{\frac12}{\displaystyle x^1_2}{x^1_2}
Exponents: a^{a^a_a}_{a^a_a} Exponents: a^{a^a_a}_{a^a_a}
FractionTest: \dfrac{a}{b}\frac{a}{b}\tfrac{a}{b}\;-\dfrac12\;1\tfrac12 FractionTest: \dfrac{a}{b}\frac{a}{b}\tfrac{a}{b}\;-\dfrac12\;1\tfrac12\;{1 \atop 2}
Functions: \sin\cos\tan\ln\log Functions: \sin\cos\tan\ln\log
GreekLetters: \alpha\beta\gamma\omega GreekLetters: \alpha\beta\gamma\omega
KaTeX: \KaTeX KaTeX: \KaTeX