Merge pull request #295 from gagern/fracspace
Improve horizontal spacing of fractions
|
@ -42,7 +42,7 @@ var groupToType = {
|
|||
open: "mopen",
|
||||
close: "mclose",
|
||||
inner: "minner",
|
||||
genfrac: "minner",
|
||||
genfrac: "mord",
|
||||
array: "minner",
|
||||
spacing: "mord",
|
||||
punct: "mpunct",
|
||||
|
@ -155,6 +155,14 @@ var isCharacterBox = function(group) {
|
|||
baseElem.type === "punct";
|
||||
};
|
||||
|
||||
var makeNullDelimiter = function(options) {
|
||||
return makeSpan([
|
||||
"sizing", "reset-" + options.size, "size5",
|
||||
options.style.reset(), Style.TEXT.cls(),
|
||||
"nulldelimiter"
|
||||
]);
|
||||
};
|
||||
|
||||
/**
|
||||
* This is a map of group types to the function used to handle that type.
|
||||
* Simpler types come at the beginning, while complicated types come afterwards.
|
||||
|
@ -469,8 +477,6 @@ var groupTypes = {
|
|||
frac.depth *= fstyle.sizeMultiplier / options.style.sizeMultiplier;
|
||||
|
||||
// Rule 15e
|
||||
var innerChildren = [makeSpan(["mfrac"], [frac])];
|
||||
|
||||
var delimSize;
|
||||
if (fstyle.size === Style.DISPLAY.size) {
|
||||
delimSize = fontMetrics.metrics.delim1;
|
||||
|
@ -478,24 +484,25 @@ var groupTypes = {
|
|||
delimSize = fontMetrics.metrics.getDelim2(fstyle);
|
||||
}
|
||||
|
||||
if (group.value.leftDelim != null) {
|
||||
innerChildren.unshift(
|
||||
delimiter.customSizedDelim(
|
||||
group.value.leftDelim, delimSize, true,
|
||||
options.withStyle(fstyle), group.mode)
|
||||
);
|
||||
var leftDelim, rightDelim;
|
||||
if (group.value.leftDelim == null) {
|
||||
leftDelim = makeNullDelimiter(options);
|
||||
} else {
|
||||
leftDelim = delimiter.customSizedDelim(
|
||||
group.value.leftDelim, delimSize, true,
|
||||
options.withStyle(fstyle), group.mode);
|
||||
}
|
||||
if (group.value.rightDelim != null) {
|
||||
innerChildren.push(
|
||||
delimiter.customSizedDelim(
|
||||
group.value.rightDelim, delimSize, true,
|
||||
options.withStyle(fstyle), group.mode)
|
||||
);
|
||||
if (group.value.rightDelim == null) {
|
||||
rightDelim = makeNullDelimiter(options);
|
||||
} else {
|
||||
rightDelim = delimiter.customSizedDelim(
|
||||
group.value.rightDelim, delimSize, true,
|
||||
options.withStyle(fstyle), group.mode);
|
||||
}
|
||||
|
||||
return makeSpan(
|
||||
["minner", options.style.reset(), fstyle.cls()],
|
||||
innerChildren,
|
||||
["mord", options.style.reset(), fstyle.cls()],
|
||||
[leftDelim, makeSpan(["mfrac"], [frac]), rightDelim],
|
||||
options.getColor());
|
||||
},
|
||||
|
||||
|
@ -1035,7 +1042,7 @@ var groupTypes = {
|
|||
var leftDelim;
|
||||
if (group.value.left === ".") {
|
||||
// Empty delimiters in \left and \right make null delimiter spaces.
|
||||
leftDelim = makeSpan(["nulldelimiter"]);
|
||||
leftDelim = makeNullDelimiter(options);
|
||||
} else {
|
||||
// Otherwise, use leftRightDelim to generate the correct sized
|
||||
// delimiter.
|
||||
|
@ -1049,7 +1056,7 @@ var groupTypes = {
|
|||
var rightDelim;
|
||||
// Same for the right delimiter
|
||||
if (group.value.right === ".") {
|
||||
rightDelim = makeSpan(["nulldelimiter"]);
|
||||
rightDelim = makeNullDelimiter(options);
|
||||
} else {
|
||||
rightDelim = delimiter.leftRightDelim(
|
||||
group.value.right, innerHeight, innerDepth, options,
|
||||
|
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
@ -11,7 +11,7 @@
|
|||
"DisplayMode": "http://localhost:7936/test/screenshotter/test.html?m=\\sum_{i=0}^\\infty \\frac{1}{i}&pre=pre&post=post&display=1",
|
||||
"DisplayStyle": "http://localhost:7936/test/screenshotter/test.html?m={\\displaystyle\\sqrt{x}}{\\sqrt{x}}{\\displaystyle \\frac12}{\\frac12}{\\displaystyle x^1_2}{x^1_2}",
|
||||
"Exponents": "http://localhost:7936/test/screenshotter/test.html?m=a^{a^a_a}_{a^a_a}",
|
||||
"FractionTest": "http://localhost:7936/test/screenshotter/test.html?m=\\dfrac{a}{b}\\frac{a}{b}\\tfrac{a}{b}",
|
||||
"FractionTest": "http://localhost:7936/test/screenshotter/test.html?m=\\dfrac{a}{b}\\frac{a}{b}\\tfrac{a}{b}\\;-\\dfrac12\\;1\\tfrac12",
|
||||
"Functions": "http://localhost:7936/test/screenshotter/test.html?m=\\sin\\cos\\tan\\ln\\log",
|
||||
"GreekLetters": "http://localhost:7936/test/screenshotter/test.html?m=\\alpha\\beta\\gamma\\omega",
|
||||
"KaTeX": "http://localhost:7936/test/screenshotter/test.html?m=\\KaTeX",
|
||||
|
|