kjen.dk

open source teaching materials

Generate png images of equations

You can use the tex2png.sh to generate images of your equations. Add your equation to a small tex file like equation.tex and run this command to generate the png file (replacing equation with the name of your tex file excluding .tex):

tex2png.sh equation

You may want to create and keep seperate tex files for each formula. This works well if you are using eg. Google Docs for drafting your report and then at the end you would like to switch to LaTeX for proper typesetting. This way you don't have to key in the formulas twice.

tex2png.sh

#!/bin/bash
texi2dvi $1.tex
dvips -E $1.dvi
convert -density 110x110 $1.ps $1.png
rm $1.ps $1.dvi $1.aux $1.log

equation.tex

\documentclass{article}
\pagestyle{empty}
\begin{document}

$\mathbf{c^2} = \mathbf{a^2} + \mathbf{b^2}$

\end{document}