Printing Latex in ipython notebook and qtconsole

207 views
Skip to first unread message

Alan Bromborsky

unread,
Dec 3, 2014, 5:35:51 PM12/3/14
to sympy
I have custom latex printing working for galgebra in "ipython notebook",
but it does not work in "ipython qtconsole" (latex printing of sympy
classes does work). When I try to print latex in qtconsole the ascii
expression for the latex is displayed. When using qtconsole should
something different be returned from _repr_latex_(self) for each class
that what is returned for notebook (what I am returning for notebook is
a latex ascii string).

My code for multivectors is -

def _repr_latex_(self):
latex_str = printer.GaLatexPrinter.latex(self)
if r'\begin{align*}' not in latex_str:
if self.title is None:
latex_str = r'\begin{equation*} ' + latex_str + r'
\end{equation*}'
else:
latex_str = r'\begin{equation*} ' + self.title + ' = '
+ latex_str + r' \end{equation*}'
else:
if self.title is not None:
latex_str = latex_str.replace('&',' ' + self.title + '
=&',1)
return latex_str

and this works in notebook.


Note that I am running python 2.7 on ubuntu 14.04 and have complete
texlive installed.

Aaron Meurer

unread,
Dec 5, 2014, 4:16:01 PM12/5/14
to sy...@googlegroups.com
The qtconsole uses matplotlib to generate latex, which supports a more
limited set of latex (in particular, I don't think it supported
\begin).

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/547F902E.7010507%40verizon.net.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages