#!/bin/bash

#Remove the .tex extention, it just messes up the bibliography
tex="${1%%\.tex}"
flags="${@:2}"
echo "$flags"

pdflatex "$flags" "$tex"
biber "$tex"
pdflatex "$flags" "$tex"
pdflatex "$flags" "$tex"

echo "Removing extra files related to $tex"
rm -v $tex.bbl
rm -v $tex.toc
rm -v $tex.aux
rm -v $tex.snm
rm -v $tex.run.xml
rm -v $tex.out
rm -v $tex.nav
rm -v $tex.log
rm -v $tex.blg
rm -v $tex.bcf

echo 
echo Done
exit 0

