lib/Tools/latex
author wenzelm
Thu Oct 07 12:27:44 1999 +0200 (1999-10-07)
changeset 7772 c7b2f68c79fb
child 7777 ddbaf6785d0d
permissions -rwxr-xr-x
Isabelle wrapper for LaTeX (and friends);
     1 #!/bin/bash
     2 #
     3 # $Id$
     4 #
     5 # DESCRIPTION: Isabelle wrapper for LaTeX (and friends)
     6 
     7 
     8 PRG=$(basename $0)
     9 
    10 function usage()
    11 {
    12   echo
    13   echo "Usage: $PRG [OPTIONS] FILE"
    14   echo
    15   echo "  Options are:"
    16   echo "    -o FORMAT    specify output format: dvi (default), dvi.gz, ps, ps.gz, pdf"
    17   echo
    18   echo
    19   echo "  Run LaTeX (and related tools) within the Isabelle environment."
    20   echo
    21   exit 1
    22 }
    23 
    24 function fail()
    25 {
    26   echo "$1" >&2
    27   exit 2
    28 }
    29 
    30 
    31 ## process command line
    32 
    33 # options
    34 
    35 OUTFORMAT=dvi
    36 
    37 while getopts "o:" OPT
    38 do
    39   case "$OPT" in
    40     o)
    41       OUTFORMAT="$OPTARG"
    42       ;;
    43     \?)
    44       usage
    45       ;;
    46   esac
    47 done
    48 
    49 shift $(($OPTIND - 1))
    50 
    51 
    52 # args
    53 
    54 FILE=""
    55 [ $# -ge 1 ] && { FILE="$1"; shift; }
    56 
    57 [ $# -ne 0 -o -z "$FILE" ] && usage
    58 
    59 
    60 ## main
    61 
    62 DIR=$(dirname "$FILE")
    63 if [ "$DIR" = "." ]; then
    64   FILEBASE=$(basename "$FILE" .tex)
    65 else
    66   FILEBASE=$(dirname "$FILE")/$(basename "$FILE" .tex)
    67 fi
    68 
    69 case "$OUTFORMAT" in
    70   dvi)
    71     $ISABELLE_LATEX "\\nonstopmode\\input{$FILEBASE.tex}"
    72     ;;
    73   dvi.gz)
    74     $ISABELLE_LATEX "\\nonstopmode\\input{$FILEBASE.tex}"
    75     gzip -f "$FILEBASE.dvi"
    76     ;;
    77   ps)
    78     $ISABELLE_LATEX "\\nonstopmode\\input{$FILEBASE.tex}"
    79     $ISABELLE_DVIPS -o "$FILEBASE.ps" "$FILEBASE.dvi"
    80     ;;
    81   ps.gz)
    82     $ISABELLE_LATEX "\\nonstopmode\\input{$FILEBASE.tex}"
    83     $ISABELLE_DVIPS -o "$FILEBASE.ps" "$FILEBASE.dvi"
    84     gzip -f "$FILEBASE.ps"
    85     ;;
    86   pdf)
    87     $ISABELLE_PDFLATEX "\\nonstopmode\\input{$FILEBASE.tex}"
    88     ;;
    89   *)
    90     fail "Bad output format '$OUTFORMAT'"
    91     ;;
    92 esac