I would like to make .png images of equations. To achive that I use pdflatex + pdfcrop + convert. But it takes more than 3 seconds on my computer to process simple $$E=mc^2$$. But I will generate dozens of images and I would like to do it as fast as possible.

pdfcrop is really slow and now I am trying to fit equation into page to except crop from my cycle. I use this:



    $ E = mc^2 $


pdflatex produces this: 1

So, it's a lot of blank space around the equation. Moreover, I would like to use latex instead of pdflatex because it's faster. But latex ignores resizebox environment. So, my questions are: Is it possible to

1) Make pdflatex scale equation to entire page?

2) Similar but using latex?

3) Or maybe there is another way to produce images of equations?


2 Answers 2


I sometimes also need a picture of a LaTeX equation. For this, I use the following tex file equation.tex:


$\displaystyle  E = m\,c^2$

Since it uses the standalone class, no pdfcrop is required and the resulting PDF contains your equation only, and nothing else, no borders, nothing. In the same folder as the equation.tex I also have a Makefile as follows

.PHONY: all clean

equation.pdf: equation.tex
    pdflatex --interaction=nonstopmode equation.tex
    convert -background white -alpha remove -density 600 equation.pdf equation.png

    --@rm -rf *.aux *.log *.lof *.bak *.loa *.log *.lot *.bbl
    --@rm -rf *.blg *.dvi *.out *.brf *.thm *.toc *.idx *.ilg *.ind
    --@rm -rf *eps-converted-to.pdf *.gnuplot *.tps
    --@rm -rf *.nav *.snm *.vrb *.lol *.tmp *.synctex *.synctex.gz
    --@rm -rf *.xwm *.pdf

and if you run the make command inside this directory, it produces the PDF with the equation and converts it to PNG. Note that on Windows, you need to enter the full path to the convert tool, e.g.

c:\programs\ImageMagick-6.8.5\bin\convert -background white -alpha remove -density 600 equation.pdf equation.png

On my box, this PDF creation and the conversion to PDF runs pretty fast. I would say less than 1/2 sec, and not 3 sec.

The above shown mwe produces this png file:



If you use TeXstudio, it has the function "preview selection". You can just select an equation and use the function.

enter image description here

enter image description here

You must log in to answer this question.

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