Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking for a tool that would batch process text-files containing formulas (possibly latex style) and convert them into a gif/png/jpg. Since I want to do a batch conversion, the tool ideally runs in cmd.exe.

What I need is probably possible with a latex installation (MiKTeX comes to mind), but if not absolutely necessary, I don't want to install 100MB+ for my need.

Is there such a tool?

share|improve this question
If I understand your task correctly (writing an HTML file), why don't you use MathJax? Or LaTeX2HTML? The latter automatically converts embedded equations. – slhck Dec 13 '12 at 13:25
up vote 3 down vote accepted

The "best" solution for quality is to use a full LaTeX installation, and then generate images via command line with e.g. mathTeX.

From my answer to a similar (but not duplicate, imho) question here at Super User:

MathTeX, licensed under the gpl, is a cgi program that lets you easily embed LaTeX math in your own html pages, blogs, wikis, etc. It parses a LaTeX math expression and immediately emits the corresponding gif (or png) image, rather than the usual TeX dvi. So just place an html tag in your document wherever you want to see the corresponding LaTeX expression.

It can either be used as a CGI script on the server and linked directly from the <img> tag, or run on the command-line to generate standalone image files. From the homepage:

mathTeX is usually run by your web server as a cgi program, obtaining its input expression from the query-string of an html tag. But you can also run mathTeX from your Unix shell, supplying all input on the command line. For example, ./mathtex.cgi "x^2+y^2" –o equation1 renders an image of x^2+y^2 in file equation1.gif.

There is actually a related project called mimeTeX that sounds more or less exactly like what you want, even though the quality is said to not be as good as with a full LaTeX installation solution as mathTeX uses, and it can naturally not handle all LaTeX cases without a LaTeX installation.

Like mathTeX, it is made primarily with webservers in mind, but in the same way, it can be run from the command line. You don't specify OS, which often indicates Windows, and compilation instructions for Windows are available on the project page linked earlier.

EDIT: I noted that the mimeTeX page provides pre-compiled binaries for Windows as well, under §5.1. Just download that and follow the instructions, as any regular Windows program. If you are on e.g. Debian or Ubuntu, both mimeTeX and mathTeX are part of the main repository.

share|improve this answer

Well, LaTeX does that, does it not?

Apart from that, a tool like MathType comes to mind - it can take input in LaTeX style and put it in let's say, a Word document.

Not sure what you're trying to accomplish? Could you elaborate some more?

share|improve this answer
Yes, I am sure that LaTeX does that. But it seems too big an installation for just creating some png's. I had something in mind of just a (rather) small .exe with which I can do something like c:\> the-tool.exe my-formula.tex -o my-formula.png – René Nyffenegger Dec 13 '12 at 8:20
Considering that my-formula.tex might be arbitrarily complex with all kinds of nested terms but will still need to be rendered correctly, what makes you think that could be done with a smaller .exe? – Nicole Hamilton Dec 13 '12 at 8:27
I am not sure if my assumption is right (and I am not a LateX user) but I was under the impression that a great deal of an installation is not needed for the rendering of such a formula. But then again, this is what it is: an assumption. – René Nyffenegger Dec 13 '12 at 9:53
@RenéNyffenegger - The main question is - why do you need something like that? What for, to be exact - since I gather you're still going to want to put those formulas into some kind of document. – Rook Dec 13 '12 at 12:13
@Idigas: I am about to write a html document that will embed these formulas with <img src=... tags. And for revision control, I do not want to store the created images themselves, but their text representation. In order to create the images, I want to create them with a batch script, possibly with make. – René Nyffenegger Dec 13 '12 at 12:29

Google has a Chart API that also supports LaTeX, which is undocumented as far as I can tell:^2


You simply place the formula behind chl=. In a practical solution for your problem you'd probably just write a batch file that submits every equation to the API and saves the result as an image file. As long as you're not making thousands of calls per day, this should be fine (Google blocks massive traffic though).

With wget this would be as simple as running the following:

wget "^2" -O "chart.png"

For tweaking the parameters, you'll find the documentation here.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .