#!/bin/bash
file=$1
pushd $(dirname $file)
base=$(basename ${file%.tex})
pdflatex --shell-escape --halt-on-error $base
pdflatex --shell-escape --halt-on-error $base
pdfcrop $base.pdf
pdf2svg $base.pdf $base-orig.svg
pdf2svg $base-crop.pdf $base-crop.svg
rm -f $base.aux $base.log $base.out $base.pdf $base-crop.pdf $base.nav $base.snm
popd
