Skip to content

tuxu/latex2svg

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

latex2svg

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

Usage

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

$ ./latex2svg.py --help
usage: latex2svg.py [-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 \\)" | ./latex2svg.py > euler-identity.svg
{"width": 4.458858333333334, "height": 0.8262691666666666, "depth": 0.012687666666666667}

Resulting SVG: Euler's identity

License

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

© 2017 Tino Wagner

About

Render LaTeX markup and equations to SVG

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages