Export latex equations in png

Posted on August 25, 2021

You want to export latex equations in png format, to add it after on a document for example.

First, you will need to install required packages in linux:

sudo apt install texlive-latex-base texlive-latex-extra texlive-lang-greek texlive-extra-utils poppler-utils netpbm

Create a file.tex like that:

documentclass[12pt]{article}
hispagestyle{empty}
usepackage{amsmath}
begin{document}
begin{equation*}
sum_{i = 0}^{i = n} frac{i}{3}
end{equation*}
end{document}

The amsmath package and the asterisk are used so we don't get the (1) numeration on the side of the equation.

The process has three steps:

1. Generate the pdf from the latex file

pdflatex file.tex

2. Crop the pdf to the equation only

pdfcrop file.pdf

3. Finally, turn it to pdf

pdftoppm file-crop.pdf|pnmtopng >file.png

If you want to get with transparent brackground

pdftoppm file-crop.pdf|pnmtopng -transparent =white >file.png