[IPython-dev] More complicated LaTeX output in IPython notebook cells.

Mark Voorhies mark.voorhies@ucsf....
Tue Jun 18 12:17:47 CDT 2013

On 06/18/2013 09:58 AM, Thomas Kluyver wrote:
> On 18 June 2013 17:48, Rick Muller <rpmuller@gmail.com> wrote:
>> which doesn't display, I think because the xyqcirc.tex stuff isn't
>> supported by mathjax.
>> Does anyone know of a workaround for this, or should I start honing my SVG
>> skills to generate a more native option?
> You're probably right about Mathjax - it's designed to handle a subset of
> TeX, and I doubt quantum circuit diagrams are in that subset ;-).
> If you need a workaround, you could write a wrapper that will do the LaTeX
> rendering in the kernel, and display it as a png.

One route for latex->png/svg is to use inkscape as a headless pdf renderer.
The default fonts are not beautiful, but it is pretty general, e.g.:

from IPython.core.display import Image, SVG

1 - p_i &=& \left(1-\frac{p_m}{N_g}\right)^n \\
\log(1 - p_i) &=& \log\left[\left(1-\frac{p_m}{N_g}\right)^n\right] \\
\log(1 - p_i) &=& n\log\left(1-\frac{p_m}{N_g}\right) \\
n &=& \frac{\log(1-p_i)}{\log(1-\frac{p_m}{N_g})}

!pdflatex example.tex

!inkscape example.pdf --export-png=example.png

!inkscape example.pdf --export-plain-svg=example.svg
SVG(filename = "example.svg")


More information about the IPython-dev mailing list