#!/bin/bash #Makes the command pretex available which will precompile #your latex file (such as a header) # #Type: # #pretex -h # #For Usage options # #Author: Cameron Bracken # #Last Modified: 2008 Oct 28 # #Licence: GNU General Public License v3 engine=pdflatex output=${1%.*} while getopts o:e:h arg do case "$arg" in e) engine="$OPTARG";; o) output=${OPTARG%.*};; h) echo "pretex: A simple utility for precompiling LaTeX Headers."; echo ""; echo "Usage: `basename $0` -h [-e engine] [-o ] texfile"; echo ""; echo "Options:"; echo ""; echo " -e Specify the name of you favorite LaTeX program (defaults to"; echo " pdflatex)."; echo ""; echo " -o Specify the basename of your main .tex file (default is to"; echo " append a .fmt to the input basename)"; echo ""; echo " -h Print out this message."; echo ""; echo "eg."; echo "For a main document main.tex and a header file preamble.tex"; echo " pretex -o main preamble.tex" echo "Then put the line"; echo " %&main"; echo "At the top of main.tex" echo "";; [?]) echo "Usage: `basename $0` -h [-e engine] [-o ] texfile"; echo "try pretex -h for help"; stop 1;; esac done shift $(($OPTIND-1)) if [[ -z "$1" ]] then # -n tests to see if the argument is non empty echo "`basename $0`: no input file" echo "try pretex -h for help" exit 1 fi call="$engine -ini -jobname=\"$output\" &$engine\ $1\dump" echo "executing: $call" $call