TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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



\usepackage{amsmath, amssymb, graphics, setspace}


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.

share|improve this question
A Suggestion: You migth want to prepare your presentation using beamer package and save yourself from the hassle :) – percusse Nov 21 '11 at 22:15
@percusse Unfortunally I need to use MSOffice apps to do this presentation. I'd like to learn beamer but now I can't. My advisor would like a MSOffice presentation =/ so I'm searching for a solution using equations without background...Anyway thanks about the suggestion. – GarouDan Nov 21 '11 at 22:20
Maybe this answer helps: tex.stackexchange.com/questions/3/compiling-documents-online/… – Count Zero Nov 21 '11 at 22:30
@GarouDan: I corrected a typo in your MWE. It appears that you had what appears to be the same typo in an earlier question, so please test your MWE before submitting them here. – Peter Grill Nov 21 '11 at 23:48
up vote 15 down vote accepted

Use convert from from ImageMagick:

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

Here is the resulting PNG file:

enter image description here

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.

share|improve this answer
Would this make the background transparent? Id add the option -transparent-color white` to convert. – Boris Nov 21 '11 at 22:31
@Boris: It seems to. See image. – Peter Grill Nov 21 '11 at 22:41
@PeterGrill The Gwenview here open your image without background as I need. But here, when I try generate it I get one with a white background (I had corrected the {). I tried the example on your link and I got the same result, a white background image. What's the problem? – GarouDan Nov 21 '11 at 22:51
I used this code and runned this commands:pdflatex 5.tex , convert -density 300 5.pdf -quality 90 5.png and I got this image. Very strange. – GarouDan Nov 21 '11 at 22:57
@GarouDan: Not sure. Try adding -transparent-color white as suggested b Boris. Maybe different versions of convert? I get the same results with or without that option. – Peter Grill Nov 21 '11 at 23:21

The following works for me:

  1. Compile to dvi using latex (not pdflatex!).

    By the way, you have a typo in your example: should be 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)}

  2. Use dvipng:

     dvipng -bg transparent -o myfile.png myfile.dvi
share|improve this answer
this works fine. Thanks. But maybe, because of this question and this discussion I need to use pdflatex, can we use it? I tried PeterGrill solution but didn't worked, even inserting the -transparent-color white as you said. – GarouDan Nov 21 '11 at 22:40
You are right: -transparent-color does not work. It seems newer version of convert understand -alpha transparent, but mine, unfortunately, does not. There are other methods listed here: imagemagick.org/Usage/masking, but neither works for me :( – Boris Nov 21 '11 at 22:53
@Looks like in this link we cant convert a white background in a transparent one. I tried several thing as there explain but nothing works. Have you had sucess? (Tried this -alpha transparent too) – GarouDan Nov 21 '11 at 23:33

I use mathurl

it'll allow you to save your equations as .png

share|improve this answer
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Martin Schröder Apr 3 at 16:11

I need this to generate equation images to a presentation.

I use an online latex equation editor that has the option to download it as .gif.

share|improve this answer
This might not be the best, but it's a valid answer to the question. I don't understand the down vote. – katu txakurra Dec 20 '15 at 16:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.