Important

This documentation covers IPython versions 6.0 and higher. Beginning with version 6.0, IPython stopped supporting compatibility with Python versions lower than 3.3 including all versions of Python 2.7.

If you are looking for an IPython version compatible with Python 2.7, please use the IPython 5.x LTS release and refer to its documentation (LTS is the long term support release).

Module: lib.latextools

Tools for handling LaTeX.

1 Class

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

Bases: SingletonConfigurable

An object to store configuration of the LaTeX tool.

backends

Preferred backend to draw LaTeX math equations. Backends in the list are checked one by one and the first usable one is used. Note that matplotlib backend is usable only for inline style equations. To draw display style equations, dvipng backend must be specified.

packages

A list of packages to use for dvipng backend. ‘breqn’ will be automatically appended when use_breqn=True.

preamble

Additional preamble to use when generating LaTeX source for dvipng backend.

use_breqn

Use breqn.sty to automatically break long equations. This configuration takes effect only for dvipng backend.

6 Functions

IPython.lib.latextools.latex_to_png(s: str, encode=False, backend=None, wrap=False, color='Black', scale=1.0)

Render a LaTeX string to PNG.

Parameters:
  • s (str) – The raw string containing valid inline LaTeX.

  • encode (bool, optional) – Should the PNG data base64 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.

  • color (string) – Foreground color name among dvipsnames, e.g. ‘Maroon’ or on hex RGB format, e.g. ‘#AA20FA’.

  • scale (float) – Scale factor for the resulting PNG.

  • used. (None is returned when the backend cannot be)

IPython.lib.latextools.latex_to_png_mpl(s, wrap, color='Black', scale=1.0)
IPython.lib.latextools.latex_to_png_dvipng(s, wrap, color='Black', scale=1.0)
IPython.lib.latextools.kpsewhich(filename)

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.

Parameters:
  • s (str) – The raw string containing valid inline LateX.

  • alt (str) – The alt text to use for the HTML.