Archive

Posts Tagged ‘dvi2png’

LaTeX formula to image (PNG)

April 19, 2011 5 comments

Problem

With LaTeX you produce a nice formula that you would like to crop and convert to an image.

Solution

Let’s see the following simple LaTeX source:

\documentclass{article}
\pagestyle{empty}

\begin{document}
$a^2+b^2=c^2$
\end{document}

Save it as file.tex and execute “latex file.tex“, which will produce a DVI output (file.dvi). The image conversion is done the following way:

dvipng -T tight -x 1200 -z 9 file.dvi -o file.png

Result:

Ref.: I saw this conversion technique in justinvh’s Markdown-LaTeX project. If your goal is to include LaTeX formulae in HTML, try his script.

Categories: latex Tags: , ,