TeX2img compiles a snippet of LaTeX — an equation, a TikZ figure, a table — and exports it as an image cropped tightly to the content. It is the go-to tool when you need beautiful mathematics somewhere LaTeX cannot reach: PowerPoint or Keynote slides, Word, a web page. It runs as a GUI app on macOS and Windows, and as a command-line version, with support for transparent backgrounds and high resolution.
What TeX2img does
Ordinary LaTeX produces a PDF with your equation set inside a full page (A4 or letter). But when you want to drop a formula into a slide, what you actually need is an image of just the formula, with no surrounding page. TeX2img fills that gap: it takes a short LaTeX snippet, compiles it, automatically crops to the bounding box of the content, and writes out a single image file.
The input can be just the math, or a fuller snippet with its own preamble. Paste only the body — leaving out \documentclass — and TeX2img wraps it in a template before compiling. Conversely, it can also take an existing .tex file, or a finished PDF, PS, or EPS, and turn that into an image.
It was originally written by Yusuke Terada, and the macOS and Windows editions are now developed by Noriyuki Abe (abenori) and others. It is a standalone application, not a web app — so it needs no internet connection, and it can use whatever style files you have installed locally.
Output formats
You can choose either vector or raster (bitmap) output. Vector formats (PDF, SVG, EPS) keep the outlines of the equation crisp at any size — blow them up several times on a slide or in print and the strokes stay sharp. Raster formats (PNG, JPEG, and so on) paste in anywhere and are convenient, but they blur when enlarged unless you raise the resolution. As a default, reaching for a vector format first is the safe choice.
| Format | Kind | Good for |
|---|---|---|
PDF | Vector | Print and re-including into LaTeX; text can be kept |
SVG | Vector | The web; stays crisp when scaled |
EPS | Vector | Illustrator and legacy print workflows |
PNG | Raster | Slides and the web; supports transparency |
JPEG | Raster | Mixing with photos (not ideal for line art) |
EMF | Vector | Pasting into Office on Windows (Windows only) |
TIFF, BMP, and GIF are available too. For PDF and SVG you can choose whether to outline the text (convert glyphs to shapes) or keep it as real text. Outlining guarantees the look reproduces even on a machine that lacks the fonts.
How it works under the hood
TeX2img is not magic — it is a front end that calls your local TeX and a few external tools in sequence. It works in roughly three stages. First it compiles the snippet with the engine you pick (pdflatex, platex, uplatex, lualatex, and so on) to make a PDF (or PS). For DVI-based paths like platex / uplatex, it then converts with dvipdfmx or dvips. Finally it processes that PDF — using Ghostscript among other tools — cropping to the content’s bounding box and writing out your chosen format.
Because of this, TeX2img needs a working TeX installation (TeX Live, MacTeX, etc.) and Ghostscript. Since you choose the engine yourself, you get the same typesetting quality you normally would — uplatex or lualatex for Japanese math and fonts, pdflatex for mostly-Western text — carried straight into the image. For the Japanese side of things, see the separate page “TeX/LaTeX and Japanese.”
Margins, resolution, and background transparency are all tunable. You can add the same margin on all four sides, produce a transparent PNG, or raise the resolution for a raster image that holds up when enlarged. For slides, adding a little margin around the equation and exporting a transparent PNG lets it blend cleanly into whatever background colour you are using.
A typical workflow
The flow is refreshingly direct. (1) Write the LaTeX for your formula or figure, (2) pick the engine and output format, (3) generate, (4) drop the resulting image into your slide or document. The GUI lets you adjust while watching a preview, and the macOS version can even paste the result straight into Illustrator, Word, or PowerPoint. Below is an example of the kind of content you might turn into an image.
\[
\int_{-\infty}^{\infty} e^{-x^2} \, dx = \sqrt{\pi}
\]Paste this into TeX2img, choose uplatex as the engine and a transparent PNG or SVG as the format, and generate — you get a single image cropped exactly to the equation. Then just drop it onto your slide.
Sometimes you want to do the same thing from the command line rather than the GUI — to batch-convert many equations, or to wire it into a build. TeX2img ships a command-line version; on Windows this is TeX2imgc.exe, a wrapper that runs the GUI in CUI mode. The basic form is to list input and output files in pairs, and the same settings as the GUI — margins, resolution, transparency, engine — are passed as options.
TeX2imgc.exe /transparent /resolution=600 equation.tex equation.pngHow it differs from standalone
A close cousin is the standalone document class. standalone crops the page to its content within a LaTeX build, and what comes out is a (cropped) PDF. It suits LaTeX-internal workflows — keeping a TikZ figure in its own file and including it in the main document, for instance.
TeX2img, by contrast, is aimed at producing standalone image files for the world outside LaTeX. A single app handles everything from compilation through cropping to writing out PNG, SVG, EMF, and the rest — so for the goal of “drop one equation onto a slide,” it is the shortest path. Use standalone when you want to stay inside a LaTeX document, and TeX2img when you want to carry the result into another application. For drawing the figures themselves, see the “TikZ” and “Including images” pages.