latex() "escapes" latex forms in IPython

153 views
Skip to first unread message

singlets

unread,
Sep 8, 2015, 8:21:20 AM9/8/15
to sympy
I'm getting double backslashes using latex() in ipython ina terminal and Jupyter notebooks:

Python 3.4.3 |Anaconda 2.2.0 (32-bit)| (default, Jun  4 2015, 15:28:02)
IPython 4.0.0 -- An enhanced Interactive Python.

In [1]: from sympy import *

In [2]: init_printing()

In [3]: var('x')
Out[3]: x

In [4]: latex(x**2/2, mode='equation*')
Out[4]: '\\begin{equation*}\\frac{x^{2}}{2}\\end{equation*}'

Using 'plain' python works 'as expected':

Python 3.4.3 |Anaconda 2.2.0 (32-bit)| (default, Jun  4 2015, 15:28:02)
>>> from sympy import *
>>> init_printing()
>>> var('x')
x
>>> latex(x**2/2, mode='equation*')
\begin{equation*}\frac{x^{2}}{2}\end{equation*}
>>>

Is there a way to disable the escaping in ipython?

Thanks,
Steve

Christophe Bal

unread,
Sep 8, 2015, 8:27:15 AM9/8/15
to sympy-list
Hello.

All of this is normal. If you use for example print(latex(x**2/2, mode='equation*')), you will have the expected behavior.


Christophe BAL
Enseignant de mathématiques en Lycée et développeur Python amateur
---
French math teacher in a "Lycée" and Python amateur developer

--
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/a2fbc76d-7f5b-441c-979c-f0c8f48874c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Singleton, Steve

unread,
Sep 8, 2015, 8:29:08 AM9/8/15
to sy...@googlegroups.com
Thanks!

--
You received this message because you are subscribed to a topic in the Google Groups "sympy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sympy/ICECiIuyOY8/unsubscribe.
To unsubscribe from this group and all its topics, 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.
Reply all
Reply to author
Forward
0 new messages