# How do I make images from LaTeX?

**URL:** <https://boards.straightdope.com/t/how-do-i-make-images-from-latex/532618>\
**Category:** Factual Questions\
**Created:** [March 16, 2010, 3:08am UTC](https://boards.straightdope.com/t/how-do-i-make-images-from-latex/532618 "2010-03-16T03:08:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [March 16, 2010, 3:08am UTC](https://boards.straightdope.com/t/how-do-i-make-images-from-latex/532618/1 "2010-03-16T03:08:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Kimstu](https://avatars.discourse-cdn.com/v4/letter/k/ecd19e/32.png) [@Kimstu](https://boards.straightdope.com/u/Kimstu)\
**Post date:** [March 16, 2010, 3:27am UTC](https://boards.straightdope.com/t/how-do-i-make-images-from-latex/532618/2 "2010-03-16T03:27:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [March 16, 2010, 3:27am UTC](https://boards.straightdope.com/t/how-do-i-make-images-from-latex/532618/3 "2010-03-16T03:27:50Z")

</div>

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](http://pages.cs.wisc.edu/~ghost/).

If you just need a few small equations rendered as PNGs, you can just abuse Wikipedia’s TeX renderer [like this](http://en.wikipedia.org/wiki/User:Friedo/TeX).

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [March 16, 2010, 4:16am UTC](https://boards.straightdope.com/t/how-do-i-make-images-from-latex/532618/4 "2010-03-16T04:16:57Z")

</div>

> [@friedo](#):
>
> If you just need a few small equations rendered as PNGs, you can just abuse Wikipedia’s TeX renderer [like this](http://en.wikipedia.org/wiki/User:Friedo/TeX).

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

---

<div class="post-metadata">

**Author:** ![Omphaloskeptic](https://avatars.discourse-cdn.com/v4/letter/o/bcef8e/32.png) [@Omphaloskeptic](https://boards.straightdope.com/u/Omphaloskeptic)\
**Post date:** [March 16, 2010, 7:13am UTC](https://boards.straightdope.com/t/how-do-i-make-images-from-latex/532618/5 "2010-03-16T07:13:19Z")

</div>

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

```auto

# 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.

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [March 18, 2010, 7:47pm UTC](https://boards.straightdope.com/t/how-do-i-make-images-from-latex/532618/6 "2010-03-18T19:47:15Z")

</div>

> [@Omphaloskeptic](#):
>
> 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
> 
> ```auto
> 
> # 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.
