mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-16 08:25:09 -04:00
Improves the spacing of & and | in LaTeX math mode output.
This commit is contained in:
parent
5857f214a9
commit
a9409319bd
@ -42,9 +42,6 @@ public final class LaTeXFormatter {
|
|||||||
if (text instanceof Simple) {
|
if (text instanceof Simple) {
|
||||||
return ((Simple) text).getText();
|
return ((Simple) text).getText();
|
||||||
} else if (text instanceof Blank) {
|
} else if (text instanceof Blank) {
|
||||||
if (mathMode)
|
|
||||||
return "\\ ";
|
|
||||||
else
|
|
||||||
return " ";
|
return " ";
|
||||||
} else if (text instanceof Character) {
|
} else if (text instanceof Character) {
|
||||||
return character(((Character) text).getChar(), mathMode);
|
return character(((Character) text).getChar(), mathMode);
|
||||||
@ -112,7 +109,15 @@ public final class LaTeXFormatter {
|
|||||||
else
|
else
|
||||||
return "\\textgreater{}";
|
return "\\textgreater{}";
|
||||||
case '&':
|
case '&':
|
||||||
|
if (inMath)
|
||||||
|
return "\\ \\&\\ ";
|
||||||
|
else
|
||||||
return "\\&";
|
return "\\&";
|
||||||
|
case '|':
|
||||||
|
if (inMath)
|
||||||
|
return "\\ |\\ ";
|
||||||
|
else
|
||||||
|
return "|";
|
||||||
case '_':
|
case '_':
|
||||||
return "\\_";
|
return "\\_";
|
||||||
case '\\':
|
case '\\':
|
||||||
|
@ -30,6 +30,10 @@ public class LaTeXFormatterTest extends TestCase {
|
|||||||
assertEquals("a\\&b", LaTeXFormatter.format(new Parser("a&b").parse()));
|
assertEquals("a\\&b", LaTeXFormatter.format(new Parser("a&b").parse()));
|
||||||
assertEquals("a$\\neg{}$b", LaTeXFormatter.format(new Parser("a¬b").parse()));
|
assertEquals("a$\\neg{}$b", LaTeXFormatter.format(new Parser("a¬b").parse()));
|
||||||
assertEquals("$a\\neg{}b$", LaTeXFormatter.format(new Parser("$a¬b$").parse()));
|
assertEquals("$a\\neg{}b$", LaTeXFormatter.format(new Parser("$a¬b$").parse()));
|
||||||
|
assertEquals("a\\&b", LaTeXFormatter.format(new Parser("a&b").parse()));
|
||||||
|
assertEquals("$a\\ \\&\\ b$", LaTeXFormatter.format(new Parser("$a&b$").parse()));
|
||||||
|
assertEquals("a|b", LaTeXFormatter.format(new Parser("a|b").parse()));
|
||||||
|
assertEquals("$a\\ |\\ b$", LaTeXFormatter.format(new Parser("$a|b$").parse()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSumProd() throws ParseException {
|
public void testSumProd() throws ParseException {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user