Earlier this week, I was preparing a presentation that was to include some simple equations I already had LaTeX for. The slideshow in question had far too many fiddly figures to justify bothering with beamer. Rather than fussing with powerpoint addins, I figured it’d be easiest to just include some images of the equations.
Rasterized images of text look horrendous in powerpoint presentations, so I figured I’d try to include postscript images instead. I found a nice post on the TeX section of stackexchange that detailed how to turn an equation into a PNG, and I adapted it for my own use.
Here’s a hacky bash script I wrote to make use of this technique. Note that if you want to do anything outside of math mode, you’ll have to remove the \[ \] surrounding \lformula. There were a few times I wanted to use \eqnarray and had to do this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
#!/bin/bash formula=$1 out_file=$2 libraries=$3 if [ -z "$formula" ] || [ -z "$out_file" ]; then echo "Syntax is: tex2ps formula output_file [ library1,library2 ]" exit 1 fi latex=' \documentclass[border=2pt]{standalone} \usepackage{amsmath} \usepackage{varwidth} \usepackage{'$libraries'} \begin{document} \begin{varwidth}{\linewidth} \[ \lformula \] \end{varwidth} \end{document}' workdir=$(mktemp -d -t 'tex2ps.XXXXXXXX') ( cd $workdir echo '\def\lformula{'$formula'}'$latex > formula.tex pdflatex formula.tex pdf2ps formula.pdf ) mv $workdir/formula.ps $out_file rm -rf $workdir |