3 if [ $# -lt 2 -o $# -gt 3 ] ; then
4 echo >&2 Usage
: run-tex format
file [interaction_mode
]
8 MAXRUNS
=${MAXLATEXRUNS:-10}
10 FORMAT
=`basename $1 .fmt`
12 if [ $# -eq 3 ] ; then
16 # The following removes the directory part, the last dot and what follows it
17 JOBNAME
=`basename ${FILE} | sed -e 's/\...*$//'`
19 # A function for computing a checksum
21 CHECKSUM
="`sum $1 | cut -f1 -d' '`"
25 # A simple function for showing a command on the screen and running it
26 # If the command fails, the whole script exits,
33 # A more complicated function for running LaTeX until the message
34 # `Rerun to get cross-references right.' does no longer show up.
35 # The number of runs is limited by MAXRUNS (default 10, if not set
36 # from environment variable MAXLATEXRUNS above.
40 until [ ${SUCCESS} = 1 ] ; do
41 run_command pdfetex
-efmt=${FORMAT} ${MODE} ${FILE}
42 fgrep
-q "Rerun to get cross-references right." ${JOBNAME}.log || SUCCESS
=1
43 RUNS
=`expr ${RUNS} + 1`
44 if [ ${RUNS} -gt ${MAXRUNS} ] ; then
45 echo >&2 Maximum number of runs reached. Stop.
48 checksum
${JOBNAME}.aux
57 # The rest is straightforward: run LaTeX....
61 # Check if bibtex needs to be run....
62 if fgrep
-q "\bibdata" ${JOBNAME}.aux
; then
63 run_command bibtex
${JOBNAME}
67 # Check if makeindex needs to be run on the .idx file....
68 if [ -s ${JOBNAME}.idx
] ; then
69 if test -r ${JOBNAME}.ist
; then
70 run_command makeindex
-s ${JOBNAME}.ist
${JOBNAME}
71 elif fgrep
-q "=\verb!*+" ${JOBNAME}.idx
; then
72 run_command makeindex
-s gind.ist
${JOBNAME}
74 run_command makeindex
${JOBNAME}
79 # Check if makeindex needs to be run on the .glo file....
80 if [ -s ${JOBNAME}.glo
] ; then
81 if fgrep
-q "=\verb!*+" ${JOBNAME}.glo
; then
82 run_command makeindex
-s gglo.ist
-o ${JOBNAME}.gls
${JOBNAME}.glo
84 run_command makeindex
-o ${JOBNAME}.gls
${JOBNAME}.glo
89 OLD_CHECKSUM
=${CHECKSUM}
91 # ...if one of the above was necessary, rerun LaTeX.
92 if [ ${RERUN} = 1 ] ; then
94 if [ "${OLD_CHECKSUM}" != "${CHECKSUM}" ] ; then
95 echo Checksum has changed. Running LaTeX again is recommended
!