Skip to content

Commit

Permalink
Improve Subtract precedence handling in TeXForm
Browse files Browse the repository at this point in the history
  • Loading branch information
axkr committed Dec 30, 2023
1 parent 7f45952 commit 13a8ba5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2146,7 +2146,7 @@ private void init() {
initTeXConverter(S.GreaterEqual, new TeXFormOperator(this, Precedence.GREATEREQUAL, "\\geq "));
initTeXConverter(S.SubtractFrom,
new TeXFormOperator(this, Precedence.SUBTRACTFROM, "\\text{-=}"));
initTeXConverter(S.Subtract, new TeXFormOperator(this, Precedence.SUBTRACT, " - "));
initTeXConverter(S.Subtract, new TeXFormOperator(this, Precedence.SUBTRACT + 1, " - "));
initTeXConverter(S.CompoundExpression,
new TeXFormOperator(this, Precedence.COMPOUNDEXPRESSION, ";"));
initTeXConverter(S.DivideBy, new TeXFormOperator(this, Precedence.DIVIDEBY, "\\text{/=}"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,12 @@ public void testTeXFormRow() {
"\\textnormal{1, 2, 3, 4}");
}

@Test
public void testTeXFormSubtract() {
check("TeXForm(Hold(Subtract(1+1/2,3+4/5)))", //
"\\text{Hold}(\\left( 1 + \\frac{1}{2}\\right) - \\left( 3 + \\frac{4}{5}\\right) )");
}

@Override
public void setUp() {
super.setUp();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2005-2013 Axel Kramer ([email protected])
* Copyright 2005-2023 Axel Kramer ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
Expand Down

0 comments on commit 13a8ba5

Please sign in to comment.