How do I fix LaTeX denominator character output?
I am using Python 2.7 with sympy. So when I try to use LaTeX output, I get an expression where the denominator value is excluded. And I can't figure out why. So for(x*y**2 - 2*x*y*z + x*z**2 + y**2 - 2*y*z + z**2)/(x**2 - 1)
I am getting something like:
Instead of something like:
He also runs his website . (Note that it works fine for short things)
The code I use is
from sympy import *
x, y, z = symblos('x y z')
expr = (x*y**2 - 2*x*y*z + x*z**2 + y**2 - 2*y*z + z**2)/(x**2 - 1)
latex(expr)
Obviously this gives TeX code, not an image.
+3
source to share
1 answer
If you never want the denominator to pull out, set long_frac_ratio to oo. The one defined below ee
has the same symptoms as your expression; note that setting the relationship makes it move to plain / below format:
>>> ee
(-2*x*y*z + x)/(x - 1)
>>> latex(ee)
'\\frac{1}{x - 1} \\left(- 2 x y z + x\\right)'
>>> latex(ee,long_frac_ratio=oo)
'\\frac{- 2 x y z + x}{x - 1}'
+4
source to share