Written and maintained by CASRAI Editorial Board
Last updated
Researchers frequently convert LaTeX equations, formulas, TikZ schematics, and tabular summaries into PNG (Portable Network Graphics) raster images to embed mathematical notation into presentation slides, web applications, learning management systems, and manuscript portals. While vector formats like SVG remain ideal for responsive websites—as detailed in our guide on converting LaTeX to SVG vectors using dvisvgm—raster PNG images offer universal compatibility across office software, markdown documentation, and graphic design tools that mishandle raw vector code. By pairing standard TeX engines with specialized utilities like dvipng and pdftoppm, research teams can generate crisp, publication-grade PNG images with transparent backgrounds and exact DPI scaling.
What it is used for in research
In academic workflows, converting LaTeX to PNG bridges the gap between typesetting precision and the practical constraints of collaborative presentation software. Common research applications include:
- Slide Decks and Posters: Presentation suites (PowerPoint, Keynote, Google Slides) often alter mathematical font metrics when importing PDFs or SVGs. Exporting formulas to 300 DPI transparent PNG images preserves exact typographic weights, radical signs, and integral brackets without risk of font substitution.
- Web Applications and Dashboards: Research portals, interactive data dashboards, and institutional repositories use lightweight PNG snippets to display complex statistical models and equations across standard web browsers.
- Graphical Abstracts and Journal Figures: Many peer-reviewed publishers require rasterized graphical abstracts and composite figures at strict resolution thresholds (typically 300 DPI for color figures and 600 to 1200 DPI for line art).
- Computational Reproducibility: Generating standalone equation snapshots ensures that research documentation retains permanent visual fidelity across different operating systems, supporting overall computational reproducibility in research workflows.
Install or access (official source only)
Converting LaTeX to PNG relies on free, official, open-source utilities included in major distributions or standard package repositories. No proprietary software or paid conversion service is needed.
1. TeX Distributions (dvipng)
The dvipng translator is bundled with standard distributions from the TeX Users Group and MiKTeX:
- TeX Live (Linux and Windows): Available from the official TeX Users Group repository at
tug.org/texlive. In Debian/Ubuntu environments, install via:sudo apt install texlive-latex-base texlive-binaries - MacTeX (macOS): Downloadable from
tug.org/mactexor installed via Homebrew:brew install --cask mactex-no-gui - MiKTeX (Windows, macOS, Linux): Available from
miktex.org. Includes package management to installdvipngautomatically on first execution.
2. Poppler Utilities (pdftoppm)
The pdftoppm tool is maintained by the Poppler project hosted on freedesktop.org (poppler.freedesktop.org). It renders PDF documents directly to image formats with high rendering fidelity:
- Ubuntu / Debian:
sudo apt install poppler-utils - macOS (Homebrew):
brew install poppler - Fedora / Red Hat:
sudo dnf install poppler-utils - Windows: Available via Chocolatey (
choco install poppler) or pre-built binary releases from the official project repository.
3. ImageMagick
ImageMagick (imagemagick.org) provides general command-line image processing. Install alongside Ghostscript (ghostscript.com) to enable PostScript/PDF interpretation delegates:
sudo apt install imagemagick ghostscript
Step-by-step task
Researchers can choose between three proven workflows depending on whether the source is an isolated equation, a compiled PDF document, or an automated compilation script. Before executing these steps, make sure you know the fundamentals of compiling LaTeX documents locally or online.
Workflow 1: Direct DVI to PNG with dvipng (Fastest for Equations)
The dvipng utility translates TeX Device Independent (DVI) files directly into PNG images. It is the fastest local method for equations because it bypasses PDF generation entirely.
- Write a minimal snippet: Create a source file named
equation.texusing thestandaloneclass:documentclass[preview]{standalone} usepackage{amsmath,amssymb} begin{document} begin{equation*} ihbar frac{partial}{partial t}Psi(mathbf{r},t) = left[ -frac{hbar^2}{2m}nabla^2 + V(mathbf{r},t) right] Psi(mathbf{r},t) end{equation*} end{document} - Compile to DVI: Run the classic
latexengine to createequation.dvi:latex equation.tex - Convert with dvipng: Run
dvipngwith DPI and transparency options:dvipng -D 300 -T tight -bg Transparent -o equation.png equation.dvi-D 300: Sets output resolution to 300 DPI for high-density rendering.-T tight: Clips the image bounding box tightly around the mathematical characters, removing default page borders.-bg Transparent: Activates an alpha channel for slide overlays. For solid white backgrounds, substitute-bg 'rgb 1.0 1.0 1.0'.-o equation.png: Designates the output target file name.
Workflow 2: PDF to PNG with pdftoppm (Best for TikZ and Full Documents)
When working with TikZ graphics, modern TrueType/OpenType fonts, or existing PDF publications, compiling via pdflatex and rasterizing with pdftoppm avoids DVI driver limitations.
- Compile to PDF: Build your graphic or document using your preferred engine:
pdflatex diagram.tex - Convert using pdftoppm: Execute the rasterization command:
pdftoppm -png -r 300 diagram.pdf diagram_page-png: Enforces PNG format output (default format is PPM).-r 300: Sets both horizontal and vertical resolution to 300 DPI. For submission to print journals, adjust to-r 600.diagram_page: The base filename prefix. The tool appends page indices automatically, creatingdiagram_page-1.png.
- Extract a single page: To render only page 3 of a multi-page document, use the
-f(first) and-l(last) arguments:pdftoppm -png -r 300 -f 3 -l 3 manuscript.pdf manuscript_page3
Workflow 3: Automated In-Document Compilation via standalone
The standalone package on CTAN can automate image conversion during document compilation:
- Configure the document class options in
figure.tex:documentclass[ preview, border=4pt, convert={density=300,outext=.png} ]{standalone} usepackage{amsmath} begin{document} $E = mc^2$ end{document} - Compile with shell escape enabled:
pdflatex -shell-escape figure.texThis invokes the system image converter in the background and writes
figure.pngalongside the PDF.
Output and how to read it
Verifying image properties ensures that converted assets conform to presentation and publisher criteria. On Linux or macOS, inspect output files using the terminal utilities file and identify (from ImageMagick):
file equation.png
identify -verbose equation.png
Typical terminal output appears as follows:
equation.png: PNG image data, 642 x 188, 8-bit/color RGBA, non-interlaced
Key technical attributes to evaluate include:
- Color Type (RGBA vs RGB): An
RGBAdesignation indicates that an alpha transparency channel is active. If your target medium has a dark theme, transparency prevents unsightly white rectangular halos around text. - Pixel Dimensions: Calculated as physical dimension in inches multiplied by DPI. A 2-inch formula at 300 DPI yields approximately 600 pixels across.
- Resolution Density: Inspect the image header to confirm density tags (e.g.
Resolution: 300x300). When placing figures in manuscripts, check our notes on including graphic files in LaTeX with graphicx and centering equations and figures in LaTeX.
Use the following matrix to select the correct DPI and background mode for common research targets:
| Target Research Medium | Recommended Resolution | Background Setting | Typical Pixel Height |
|---|---|---|---|
| Conference Slides (1080p / 4K) | 150 – 300 DPI | Transparent (-bg Transparent) |
80 – 160 px |
| Journal Graphical Abstract | 300 – 600 DPI | Solid White (-bg 'rgb 1.0 1.0 1.0') |
200 – 400 px |
| Web / LMS Content (Canvas, Moodle) | 150 – 200 DPI | Transparent (-bg Transparent) |
60 – 120 px |
| Conference Poster Print (A0 / Arch E) | 600 – 1200 DPI | Solid White (-bg 'rgb 1.0 1.0 1.0') |
400 – 800 px |
Troubleshooting
Review these solutions for common compilation and conversion roadblocks:
1. ImageMagick Security Policy Block
Error Message: attempt to perform an operation not allowed by the security policy 'PDF'
Diagnosis: Modern Linux distributions disable PostScript and PDF conversion inside ImageMagick’s policy.xml to mitigate Ghostscript security risks (CVE vulnerabilities).
Fix: The cleanest workaround is to switch to pdftoppm, which uses Poppler’s native rasterizer and bypasses Ghostscript completely:
pdftoppm -png -r 300 input.pdf output_prefix
If you must use ImageMagick and maintain administrator rights, edit /etc/ImageMagick-6/policy.xml (or ImageMagick-7) and change the line:
<policy domain="coder" rights="none" pattern="PDF" />
to:
<policy domain="coder" rights="read|write" pattern="PDF" />
2. Pixelated or Blurry Formulas
Symptom: Equations appear jagged or fuzzy when projected onto presentation screens.
Diagnosis: In dvipng or pdftoppm, the default resolution was not increased from standard screen preview density (72–150 DPI).
Fix: Re-run conversion specifying -D 300 or -D 600 in dvipng, or -r 300 in pdftoppm. If using ImageMagick, place the -density 300 flag before the input filename so the PDF is rasterized at high resolution before rendering.
3. Dark Halos Around Characters in Slide Presentations
Symptom: Transparent PNG equations display dirty gray or dark halos around thin font strokes when placed over colored slide backgrounds.
Diagnosis: Font antialiasing blended character edges against an assumed black or white background during rasterization without proper alpha pre-multiplication.
Fix: Use dvipng with -bg Transparent and modern Type 1 Computer Modern or Latin Modern fonts. In LaTeX, load the Latin Modern package in your preamble:
usepackage{lmodern}
4. Missing Font Glyphs in dvipng
Symptom: dvipng: warning: font ... not found or missing symbol characters in formulas.
Diagnosis: dvipng could not locate pre-rendered bitmap fonts (PK fonts) or vector font definitions for specialized math packages.
Fix: Ensure scalable font packages are installed on your system (e.g. cm-super on Debian/Ubuntu):
sudo apt install cm-super texlive-fonts-recommended
Alternatively, compile the document with pdflatex and use pdftoppm, which handles embedded PDF fonts natively.
5. Shell Escape Disabled with standalone
Symptom: Compiling with standalone creates the PDF but fails to produce the PNG image.
Diagnosis: TeX engines disable external shell execution by default for security.
Fix: Pass the -shell-escape flag to the compiler:
pdflatex -shell-escape document.tex
Free alternatives (table)
The table below summarizes free, open-source software alternatives for exporting LaTeX equations and documents to raster image formats.
| Tool / Package | Primary Input | Resolution Control | Transparency Support | Best Academic Use Case |
|---|---|---|---|---|
| dvipng | DVI (from latex) |
Explicit DPI flag (-D) |
Native alpha channel (-bg Transparent) |
High-speed batch conversion of math formulas and equations for slides. |
| pdftoppm | PDF (from pdflatex) |
Explicit DPI flag (-r) |
Yes (via -png) |
Complex TikZ diagrams, full documents, and multi-page manuscripts. |
| standalone (CTAN) | LaTeX .tex source |
Configurable via class options | Configurable via external driver | Automated compilation pipelines and continuous integration (CI) builds. |
| ImageMagick (magick) | PDF, EPS, PS | Configurable via -density |
Supported (-background none) |
Post-processing figures, cropping, color adjustment, and format conversions. |
| dvisvgm + rasterizer | DVI, PDF | Vector SVG output scaled to target DPI | Full vector transparency | Maintaining scalable master SVGs with secondary raster export. |
| matplotlib (mathtext) | Python string | Configurable (dpi=300) |
Yes (transparent=True) |
Generating equation figures directly inside Python data analysis scripts. |
FAQ
How do I convert LaTeX to a PNG with a transparent background?
For standalone equations, use dvipng with the transparency flag: dvipng -D 300 -T tight -bg Transparent -o formula.png formula.dvi. If converting from a compiled PDF using pdftoppm, PNG output generates transparent backgrounds automatically when the underlying LaTeX document has no background color applied.
What DPI should I use for LaTeX equation images in presentations?
A resolution of 300 DPI is the recommended standard for presentation slides. It ensures that math symbols remain sharp when projected onto 1080p and 4K screens while keeping file sizes lightweight. For print posters or journal submissions, use 600 DPI to meet publisher line-art thresholds.
Can I convert a multi-page LaTeX PDF to PNG images automatically?
Yes. Running pdftoppm -png -r 300 manuscript.pdf output_page converts every page in the PDF into a separate indexed PNG image (e.g. output_page-1.png, output_page-2.png). To restrict conversion to a single page range, use the -f and -l options.
Why is my converted PNG formula blurry when inserted into PowerPoint?
Blurriness occurs when an image converted at low default screen resolution (72 or 96 DPI) is scaled up inside PowerPoint. To prevent blurriness, render the image at 300 DPI or higher before importing it into your slide deck.
How do I export TikZ graphics directly to PNG?
Because TikZ relies on PDF-specific driver commands, compile your TikZ graphic using pdflatex with the standalone document class to create a tightly cropped PDF. Then convert the PDF using pdftoppm -png -r 300 graphic.pdf graphic_out.
Sources (official docs)
- CTAN / TeX Live dvipng Package Documentation: Jan-Åke Larsson et al., dvipng: A DVI-to-PNG Translator. Comprehensive manual on DVI rasterization, font antialiasing, and CLI options. Checked November 8, 2026. https://ctan.org/pkg/dvipng
- Poppler / freedesktop.org pdftoppm Manual: The Poppler Developers, pdftoppm: Portable Document Format (PDF) to Portable Pixmap (PPM) Converter. Official utility manual for PDF-to-image conversion. Checked November 8, 2026. https://poppler.freedesktop.org/
- CTAN standalone Package Documentation: Martin Scharrer, The standalone Package & Class. Official CTAN package documentation on trimming and automated image conversion via
-shell-escape. Checked November 8, 2026. https://ctan.org/pkg/standalone - ImageMagick Command-Line Tools & Security Policy: ImageMagick Development Team, ImageMagick Command-Line Processing and Security Architecture. Guidelines on rasterization density and delegate policies. Checked November 8, 2026. https://imagemagick.org/script/command-line-processing.php
- The LaTeX Project Documentation: The LaTeX Project, LaTeX2e Documentation and Help Resources. Checked November 8, 2026. https://www.latex-project.org/help/documentation/







