# [Tex/LaTex] How to export an equation as an image without background

equationsgraphicsmath-mode

For example, if we have a equation on a file like:

\documentclass[12pt]{standalone}
\usepackage{varwidth}

\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{amsmath, amssymb, graphics, setspace}
\newcommand{\mathsym}[1]{{}}
\newcommand{\unicode}[1]{{}}
\newcounter{mathematicapage}

\begin{document}
\begin{varwidth}{50in}
\begin{equation*}
P\left(H_h|E_e\right)=\frac{P\left(E_e|H_h\right)P\left(H_h\right)}{P\left(E_e\right)}
\end{equation*}
\end{varwidth}
\end{document}


How export it as a png image, without background? (Just the equation, without white background).

(I'd like a full comand to do this, compiling the .tex file and getting a png image as output)

I need this to generate equation images to a presentation.

#### Best Answer

Use convert from from ImageMagick:

pdflatex formula.tex
convert -density 300 formula.pdf -quality 90 formula.png


Here is the resulting PNG file:

This solutions is from TeX to image over command line, which you should see as this will allow you to specify the formula on the command line.