Render LaTeX markup and equations to SVG
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Python wrapper and CLI utility to render LaTeX markup and equations as SVG using dvisvgm.


Python 3 module

from latex2svg import latex2svg
out = latex2svg(r'\( e^{i \pi} + 1 = 0 \)')
print(out['depth'])  # baseline position in em
print(out['svg'])  # rendered SVG

CLI utility

$ ./ --help
usage: [-h] [--preamble PREAMBLE]

Render LaTeX code from stdin as SVG to stdout. Writes metadata (baseline
position, width, height in em units) as JSON to stderr.

optional arguments:
  -h, --help           show this help message and exit
  --preamble PREAMBLE  LaTeX preamble code to read from file

$ echo "\\( e^{i \\pi} + 1 = 0 \\)" | ./ > euler-identity.svg
{"width": 4.458858333333334, "height": 0.8262691666666666, "depth": 0.012687666666666667}

Resulting SVG: Euler's identity


This project is licensed under the MIT license. See for details.

© 2017 Tino Wagner