I am trying to use the following python code
Solved (Hint by @TheFool): By putting latex() into the print function it works.
from sympy import *
from sympy.printing.mathml import mathml
init_printing(use_unicode=True) # allow LaTeX printing
# independent variables
x, y, z = symbols('x y z', real = True)
# parameters
nu, rho = symbols('nu rho', real = True, constant = True, positive = True)
# dependent variables
u, v, w = symbols('u v w', real = True, cls = Function)
print(latex(diff(u(x,y,z),x)))
The output looks like
'\\frac{\\partial}{\\partial x} u{\\left (x,y,z \\right )}'
.
How can I remove the additional backslashes and the quotation marks at the beginning and at the end of the output?
from sympy import Matrix, print_latex
X = Matrix([1,2,3])
print_latex(X)
out: \left[\begin{matrix}1\\2\\3\end{matrix}\right]
(only prints out like that if your in a notebook environment)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With