How to render multiple expressions in MathJax in IPython Notebook?

71 views
Skip to first unread message

ssin...@coe.edu

unread,
Mar 11, 2015, 9:22:14 PM3/11/15
to sy...@googlegroups.com
Hello,

Probably a basic question..

This works fine for pretty printing ascii, but I'd like to render 'typeset' versions of the expressions:

p = [assoc_legendre(l, ml, x) for l in range(5) for ml in range(l)]
for f in p:
    pprint(f)

If it matters: running sympy 0.7.6, Ipynb 3.0, FF36 linux, executed init_printing()

Thanks,
Steve

Aaron Meurer

unread,
Mar 13, 2015, 10:11:17 PM3/13/15
to sy...@googlegroups.com
pprint always prints in 2D text. The easiest way to do what you want
is something like

from sympy import latex
from IPython.display import Math
for f in p:
Math(latex(f))

You can also use IPython.display.Latex, which requires you to use
latex(f, mode='inline').

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/4d60b855-3824-4a81-915f-d25d4999882d%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

singlets

unread,
Mar 14, 2015, 1:04:12 PM3/14/15
to sy...@googlegroups.com


On Friday, March 13, 2015 at 9:11:17 PM UTC-5, Aaron Meurer wrote:
pprint always prints in 2D text. The easiest way to do what you want
is something like

from sympy import latex
from IPython.display import Math
for f in p:
    Math(latex(f))


*headslap* I tried a similar approach, but had the order of Math()/latex() backwards. Obvious in hindsight...thanks.
 
You can also use IPython.display.Latex, which requires you to use
latex(f, mode='inline').


Again thank you...I'm still learning which bits belong to sympy and which bits belong ipynb. This helps.
 
Steve

Reply all
Reply to author
Forward
0 new messages