I have input of a whole lot of math expressions and equations, and I'd like to print out latex representation for each on them. So far I have tried Sage and sympy, but the tricky part is to not-reorder terms in expressions.
So, if my input is this, something that can be eval
-ed in python:
(C - A*x) / B
I want output that will be something like this:
\frac{C - A x}{B}
What I don't want is something like this:
\frac{-(A x - C)}{B}
\frac{1}{B}(C - A x)
etc...
Can this be achieved? I'm slowly losing hope...
EDIT:
The input expressions are diverse, some containing square roots, nested parentheses, exponents etc. Looking for a generic solution.
Here is what doesn't work so far:
1) Sage:
sage: var('A B C x y')
(A, B, C, x, y)
sage: latex(y == (C - A*x) / B)
y = -\frac{A x - C}{B}
2) sympy:
>>> from sympy import *
>>> x = Symbol('x')
>>> A = Symbol('A')
>>> B = Symbol('B')
>>> C = Symbol('C')
>>> latex((C - A*x) / B)
'\\frac{1}{B} \\left(- A x + C\\right)'