mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-13 14:56:29 -04:00
Improves the spacing of & and | in LaTeX math mode output.
This commit is contained in:
parent
5857f214a9
commit
a9409319bd
@ -42,10 +42,7 @@ public final class LaTeXFormatter {
|
||||
if (text instanceof Simple) {
|
||||
return ((Simple) text).getText();
|
||||
} else if (text instanceof Blank) {
|
||||
if (mathMode)
|
||||
return "\\ ";
|
||||
else
|
||||
return " ";
|
||||
return " ";
|
||||
} else if (text instanceof Character) {
|
||||
return character(((Character) text).getChar(), mathMode);
|
||||
} else if (text instanceof Decorate) {
|
||||
@ -112,7 +109,15 @@ public final class LaTeXFormatter {
|
||||
else
|
||||
return "\\textgreater{}";
|
||||
case '&':
|
||||
return "\\&";
|
||||
if (inMath)
|
||||
return "\\ \\&\\ ";
|
||||
else
|
||||
return "\\&";
|
||||
case '|':
|
||||
if (inMath)
|
||||
return "\\ |\\ ";
|
||||
else
|
||||
return "|";
|
||||
case '_':
|
||||
return "\\_";
|
||||
case '\\':
|
||||
|
@ -30,6 +30,10 @@ public class LaTeXFormatterTest extends TestCase {
|
||||
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\\&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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user