Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
3  
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
add comment

2 Answers

up vote 9 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
1  
Would this make the background transparent? I`d 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
show 6 more comments

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
add comment

Your Answer

 
discard

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.