Question

How do you get iPython to output results using latex?

For example, like on this page: http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/master/examples/notebooks/SymPy%20Examples.ipynb

If I execute the code:

Rational(3,2)*pi + exp(I*x) / (x**2 + y)

I get output:

Out[13]: 3*pi/2 + exp(I*x)/(x**2 + y)

I want to see output in latex as shown in the link above.

Was it helpful?

Solution 2

As done in the link you posted and mentioned by @tcaswell you need to "activate" the latex printing using

from sympy.interactive import printing
printing.init_printing(use_latex=True)

the use_latex=True statement is required with sympy 0.7.2 but not with 0.7.3.

OTHER TIPS

An updated answer for those googlers:

from IPython.display import Math
Math('3 \cdot \\frac{\pi}{2} + e^{\\frac{I*x}{x^2 + y}}')

A bit more clumsy than SymPy, but doesn't need an extra package.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top