IPython Documentation

Table Of Contents

Previous topic

Module: lib.irunner

Next topic

Module: lib.pretty

This Page


This documentation is for an old version of IPython. You can find docs for newer versions here.

Module: lib.latextools

Tools for handling LaTeX.


  • Brian Granger

1 Class

class IPython.lib.latextools.LaTeXTool(**kwargs)

Bases: IPython.config.configurable.SingletonConfigurable

An object to store configuration of the LaTeX tool.

7 Functions

IPython.lib.latextools.latex_to_png(s, encode=False, backend=None, wrap=False)

Render a LaTeX string to PNG.


s : str

The raw string containing valid inline LaTeX.

encode : bool, optional

Should the PNG data bebase64 encoded to make it JSON’able.

backend : {matplotlib, dvipng}

Backend for producing PNG data.

wrap : bool

If true, Automatically wrap s as a LaTeX equation.

None is returned when the backend cannot be used. :

IPython.lib.latextools.latex_to_png_mpl(s, wrap)
IPython.lib.latextools.latex_to_png_dvipng(s, wrap)

Invoke kpsewhich command with an argument filename.

IPython.lib.latextools.genelatex(body, wrap)

Generate LaTeX document for dvipng backend.

IPython.lib.latextools.latex_to_html(s, alt='image')

Render LaTeX to HTML with embedded PNG data using data URIs.


s : str

The raw string containing valid inline LateX.

alt : str

The alt text to use for the HTML.

IPython.lib.latextools.math_to_image(s, filename_or_obj, prop=None, dpi=None, format=None)

Given a math expression, renders it in a closely-clipped bounding box to an image file.

A math expression. The math portion should be enclosed in dollar signs.
A filepath or writable file-like object to write the image data to.
If provided, a FontProperties() object describing the size and style of the text.
Override the output dpi, otherwise use the default associated with the output format.
The output format, eg. ‘svg’, ‘pdf’, ‘ps’ or ‘png’. If not provided, will be deduced from the filename.