Last active
January 3, 2017 09:28
-
-
Save Baekalfen/4d343f7d85ffbfe1b985ff7e60daa6d7 to your computer and use it in GitHub Desktop.
My perfect Latex-to-PDF script. Clean output and also compiles bibtex references.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# TEXNAME='${echo $1 | egrep -o "^([^.]*)"}' | |
TEXNAME=$(echo $1 | egrep -wo "^([^.]*)") # Strip up to first extension | |
echo $TEXNAME | |
cd $(dirname "$TEXNAME") | |
PATH=/usr/local/texlive/2014/bin/x86_64-darwin:$PATH | |
pdflatex -interaction=batchmode "$TEXNAME.tex" | |
echo "" | |
bibtex "$TEXNAME.aux" | |
echo "" | |
OUTPUT="$(pdflatex -interaction=nonstopmode "$TEXNAME.tex" | egrep 'LaTeX (Error|Warning): ')" | |
echo "${OUTPUT}" | |
if echo "${OUTPUT}" | grep -q 'Rerun to get cross-references right.'; then | |
echo "" | |
echo "Running Latex again to get cross-references" | |
pdflatex -interaction=nonstopmode "$TEXNAME.tex" | grep 'LaTeX Warning: ' | |
fi | |
open "$TEXNAME.pdf" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage is "./pdf.sh main.tex" or "./pdf.sh main." or "./pdf.sh main" or "./pdf.sh main.ThisIsStripped"