How do I make images from LaTeX?

I need to output some images of the sort that you see in technical articles on Wikipedia, or similar sites. How do I go about doing that? I’m running MiKTeX 2.7 on Windows.

What kind of images, in what format? Just the typeset pages themselves?

I’m not familiar with MikTex specifically, but all TeXes should be able to output directly to PostScript. From there you should be able to render it as an image or PDF file, using something like GhostScript.

If you just need a few small equations rendered as PNGs, you can just abuse Wikipedia’s TeX renderer like this.

This is exactly the format I’m looking for, except that I need enough images that I don’t want to do anything manually.

Here’s a sequence of commands that you can turn into a script. Start with a TeX/LaTeX file eqn.tex that will output a single page, entirely blank except for your equation (or whatever)–note that this means you need a hispagestyle{empty} or equivalent. Now


# create DVI (MiKTeX provides latex.exe)
latex eqn.tex
# create tight-bounding-box EPS (MiKTeX provides dvips.exe)
dvips -E -o eqn.eps eqn.dvi
# turn this into a PDF (MiKTeX provides epstopdf.exe)
epstopdf eqn.eps
# now finally make a PNG (use gswin32c.exe from the GhostScript package)
# - gswin32c --help lists the available devices, if you don't want png16m output
# - set the resolution as desired with -r (here 300dpi)
gswin32c -r300 -sDEVICE=png16m -dBATCH -dNOPAUSE -sOutputFile=eqn.png eqn.pdf


Some of these commands can be chained together to reduce the number of temporary files this generates, if you like.

This is exactly what I needed. Thank you.