Last active
February 23, 2017 21:50
-
-
Save late-in-autumn/c218a5b24cec98559fa02995b4c5e337 to your computer and use it in GitHub Desktop.
This file contains 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 | |
## latexbuild.sh: a simple wrapper around latexmk and various LaTeX-related tools | |
## automated shadow build of LaTeX files, making working directory clean | |
## Depends on: latexmk, xetex, synctex, coreutils, bash | |
## Usage: latexbuild.sh <filename> | |
FILENAME=$1 | |
BASENAME=$(basename ${FILENAME}|cut -d. -f1) | |
if [ -d ./build ] | |
then | |
cd build | |
else | |
mkdir build | |
if [ $? -eq 0 ] | |
then | |
cd build | |
else | |
echo "Error creating shadow build directory, exiting." | |
cd .. | |
exit -2 | |
fi | |
fi | |
latexmk -xelatex -verbose -file-line-error -synctex=0 -interaction=nonstopmode ../${FILENAME} | |
if [ $? -ne 0 ] | |
then | |
echo "Error occurred, see build/${BASENAME}.log for details" | |
cd .. | |
exit -1 | |
fi | |
mv ${BASENAME}.pdf .. | |
if [ $? -ne 0 ] | |
then | |
echo "Error moving output PDF to working directory, PDF can still be retrieved in build/ directory." | |
cd .. | |
exit -3 | |
fi | |
cd .. | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment