depletedboi
depletedboi

Reputation: 71

Display sympy expressions in latex using pycharm/ipython

I am using SymPy and the scientific mode of PyCharm for symbolic calculations.

I would like to display latex code for printed out expressions in the integrated console. Using qtconsole this works fine, but i don't know how to make this work in the PyCharm console. I use sympy.init_printing() but the equations often look messy and are hard to read. Sympy also can convert symbolic expressions into strings containing the latex code.

so i would only need to know how to display the compiled latex expression, although it would be more convenient to make it work directly like in qtconsole.

I am using PyCharm 2019.3.1 with python 3.8.1 and the ipython console.

Does anyone know how to do this?

Upvotes: 7

Views: 2451

Answers (1)

Pascià
Pascià

Reputation: 61

Assuming I understand your question correctly, this can be done using display from IPython:

import sympy as sym
from IPython.display import display

x, a, b = sym.symbols('x a b')
func = (a*x**b)/(a+b)

display(func)

This will print the compiled LaTeX .

Upvotes: 3

Related Questions