Added support for \not (#140)

* Added support for \not

* fix grammar in comment
This commit is contained in:
Kevin Barabash
2017-08-23 13:24:17 -04:00
committed by GitHub
parent 201193233e
commit c6647e3303
8 changed files with 51 additions and 0 deletions

View File

@@ -117,6 +117,40 @@ const buildExpression = function(expression, options, isRealGroup) {
}
}
// Process \\not commands within the group.
// TODO(kevinb): Handle multiple \\not commands in a row.
// TODO(kevinb): Handle \\not{abc} correctly. The \\not should appear over
// the 'a' instead of the 'c'.
for (let i = 0; i < groups.length; i++) {
if (groups[i].value === "\u0338" && i + 1 < groups.length) {
const children = groups.slice(i, i + 2);
children[0].classes = ["mainrm"];
// \u0338 is a combining glyph so we could reorder the children so
// that it comes after the other glyph. This works correctly on
// most browsers except for Safari. Instead we absolutely position
// the glyph and set its right side to match that of the other
// glyph which is visually equivalent.
children[0].style.position = "absolute";
children[0].style.right = "0";
// Copy the classes from the second glyph to the new container.
// This is so it behaves the same as though there was no \\not.
const classes = groups[i + 1].classes;
const container = makeSpan(classes, children);
// LaTeX adds a space between ords separated by a \\not.
if (classes.indexOf("mord") !== -1) {
// \glue(\thickmuskip) 2.77771 plus 2.77771
container.style.paddingLeft = "0.277771em";
}
// Ensure that the \u0338 is positioned relative to the container.
container.style.position = "relative";
groups.splice(i, 2, container);
}
}
return groups;
};

View File

@@ -661,6 +661,9 @@ const buildExpression = function(expression, options) {
const group = expression[i];
groups.push(buildGroup(group, options));
}
// TODO(kevinb): combine \\not with mrels and mords
return groups;
};

View File

@@ -504,6 +504,7 @@ defineSymbol(math, main, rel, "\u2190", "\\gets");
defineSymbol(math, main, rel, ">", "\\gt");
defineSymbol(math, main, rel, "\u2208", "\\in");
defineSymbol(math, main, rel, "\u2209", "\\notin");
defineSymbol(math, main, rel, "\u0338", "\\not");
defineSymbol(math, main, rel, "\u2282", "\\subset");
defineSymbol(math, main, rel, "\u2283", "\\supset");
defineSymbol(math, main, rel, "\u2286", "\\subseteq");