summaryrefslogtreecommitdiff
path: root/2005/flow-accounting-ols2005/OLS2005/Texmf/latex2dvi
blob: 8def5938b10e1d599694b95b7187b10c688c2105 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /bin/sh

# This helper script runs pdflatex, LaTeX, and/or BibTeX in a loop until the output file
# (DVI/PDF) stabilizes.

if [ $# -ne 1 ]; then
    echo "usage: $0 TEX-FILE" >&2
    exit 2
fi


input="${1%.tex}"
aux="$1".aux
oaux="$1".oaux

# Go through the procedure twice; once for LaTeX to
# generate a stable DVI file, then once with pdflatex
# to generate a stable PDF file.  We really do want both...

for LATEX in latex pdflatex ; do
  rm -f "$aux" "$oaux"

  # Run LATEX once.  The output file we get from this is probably junk, but
  # what we're interested in is the .aux file.  If it fails, abort.
  echo "+ $LATEX -interaction=nonstopmode \"$input\""
  $LATEX -interaction=nonstopmode "$input" || exit 1

  # Determine whether we need to run BibTeX.  This (should) only ever have
  # to be done once.  Again, if BibTeX fails, abort.
  if grep -q bibdata "$aux"; then
      echo "+ bibtex \"$input\""
      bibtex "$input" || exit 1
  fi

  # Save the old .aux file.
  cp "$aux" "$oaux"

  # Now run LaTeX over and over again until the .aux file stops changing.
  # We use \batchmode for these cycles - the user has already seen any
  # diagnostics of interest.
  while :; do
      echo "+ $LATEX -interaction=batchmode \"$input\""
      $LATEX -interaction=batchmode "$input" || exit 1
      if cmp -s "$aux" "$oaux"; then
	  break
      fi
      cp "$aux" "$oaux"
  done

done
personal git repositories of Harald Welte. Your mileage may vary