Skip to content

Instantly share code, notes, and snippets.

@rldotai
Created December 19, 2015 07:10
Show Gist options
  • Select an option

  • Save rldotai/572acbc6be1327a0370c to your computer and use it in GitHub Desktop.

Select an option

Save rldotai/572acbc6be1327a0370c to your computer and use it in GitHub Desktop.
A quick way to build LaTeX files while purging the auxiliary files pdflatex generates.
#!/bin/bash
# Generate a PDF from a `.tex` file, then remove the auxiliary files with the same base name.
#
# Usage:
# ./quicktex.sh myfile.tex
# the first argument should be the tex file, either with or without extension
file="$1"
# remove the suffix (if it's .tex)
file="${file%.tex}"
[ "${file:0:1}" == "/" ] || file="${PWD}/${file}"
pdffile="${file%.tex}.pdf"
# run pdflatex and bibtex, then pdflatex again to get references right
pdflatex "${file}" && bibtex "${file}" && pdflatex "${file}" && pdflatex "${file}"
# clean the files
rm -f "$file""."{aux,bak,bbl,blg,log,out,toc,tdo} #brace expansion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment