At the moment, I'm using mimetex to automatically convert a bunch of equations into gif-images.

The program is fast, but the images look pretty bad:

enter image description here

How can I (quickly) convert a LaTeX equation into an SVG image on the command line?


pdf2svg works quite well.

Use \pagestyle{empty} to avoid page numbers and pdfcrop (package texlive-extra-utils) to remove empty space around the equations

  • 1
    That works well! It's a little bit slow, and I have a feeling I'm still not doing it quite right (here's the script I'm using). Thanks a lot! – Stefano Palazzo Apr 2 '11 at 23:13
  • Use pdflatex instead of latex, dvips and ps2pdf – Florian Diesch Apr 2 '11 at 23:32
  • 1
    It's no faster, but works pretty well. I'd really like a solution that does this job in under 100 ms, and preferably without writing a whole load of files, but it works and I'm happy. :-) This is the result of your answer so far. – Stefano Palazzo Apr 3 '11 at 0:53
  • @Florian Diesch; the example link seems broken, can you remedy, perhaps embedding the example image? – enzotib Jul 11 '11 at 9:55

A new option is to use mathjax-node from npm. Install a distribution of node, then use npm to install mathjax-node:

$ npm install --global mathjax-node

Edit: You now have to install mathjax-node-cli, however, mathjax-node-cli doesn't show up (yet), so I had to pass the github repo:

$ npm install --global https://github.com/mathjax/mathjax-node-cli.git

Once installed, you will be able to use tex2svg:

$ /usr/local/lib/node_modules/mathjax-node-cli/bin/tex2svg \
'\sin^2{\theta} + \cos^2{\theta} = 1' > identity.svg

And the result:

result of tex2svg, rasterized at 300dpi

The generated SVG file renders properly inside a browser but cannot be displayed using standard image tools.

  • 1
    there is no bin in /usr/local/lib/node_modules/mathjax-node/ – Necktwi Mar 27 '17 at 17:52

dvisvgm works quickly and nicely in my experience. It's in TeX Live 2010.


Have you tried ekee? It's a clone of LatexIt for Mac, it's great! It's hosted on http://rlehy.free.fr/.

enter image description here

  • 2
    ekee link says currently unmaintained. ... with last update circa 2008. klatexformula might be an alternative. – l --marc l Jun 24 '19 at 23:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.