Skip to content

Instantly share code, notes, and snippets.

@Drunkar
Created February 27, 2014 14:05
Show Gist options
  • Save Drunkar/9250704 to your computer and use it in GitHub Desktop.
Save Drunkar/9250704 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# This is a xelatex engine for TeXnicle.
#
# It runs xelatex the desired number of times, optionally running bibtex after the first run.
#
# <support>nCompile,doBibtex</support>
#
# xelatex.engine
# TeXnicle
#
# DO NOT EDIT THIS ENGINE. It will be overwritten each time TeXnicle starts up.
#
if [ $# -lt 2 ]
then
echo "usage: <file-to-compile> <working-directory> (<num compile> <do bibtex>)"
exit
fi
# Executable values
PATH=/usr/texbin:/usr/local/bin:$PATH
ENGINE=/usr/texbin/xelatex
BIBTEX=/usr/texbin/bibtex
# Process inputs.
# TeXnicle passes the file to be processed as the first input to this
# script and the working directory as the second input. Other options follow.
mainfile=$1
outputDir=$2
nCompile=$3
doBibtex=$4
doPS2PDF=$5
echo "****************************"
echo "*** Compiling $mainfile"
echo "*** Output dir $outputDir"
echo "*** Ncompile $nCompile"
echo "*** Do bibtex $doBibtex"
echo "****************************"
# Go to the working directory
cd "$outputDir"
# Do the correct number of typesetting runs
count=1
while [ $count -le $nCompile ]
do
echo " "
echo "***------------------------------------------------------------"
echo "*** Run $count..."
echo "***------------------------------------------------------------"
$ENGINE -synctex=1 -file-line-error -interaction=nonstopmode --shell-escape "$mainfile"
# if this is after the first run, run bibtex if requested
if [ $count -eq 1 ]
then
if [ $doBibtex -eq 1 ]
then
echo "*** Running bibtex..."
$BIBTEX "$mainfile"
fi
fi
count=$(( $count + 1 ))
done
echo "*** xelatex.engine has completed."
# END
@Drunkar
Copy link
Author

Drunkar commented Feb 27, 2014

for texnicle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment