#!/bin/bash # # Syntax: ltl [-p] [-f] [-h] # # Purpose: Processes the most recently changed .tex file in the # current directory. If option -p is specified, the # corresponding postscript file will also be generated. # If option -f is specified, the corresponding pdf file # will also be generated (also works for beamer presentations). # The -h flag shows the help info for this command. # Created: Aug 19, 1998 by Bart De Schutter # Last revised: Nov 18, 2012 by Bart De Schutter # # See http://www.deschutter.info/util/scripts.html for the latest version of # this script. # Status: public # Category: latex make_ps=0 make_pdf=0 while getopts :pfh option do case "$option" in p) make_ps=1;; f) make_pdf=1;; h) sed '/^$/q;/^#!/d;s/^# //;s/^#//' $0 >&2 exit 1;; \?) echo >&2 echo >&2 "Unknown option: $OPTARG" echo >&2 sed '/^$/q;/^#!/d;s/^# //;s/^#//' $0 >&2 exit 1;; esac done shift $(($OPTIND-1)) if [ $# -ne 0 ]; then echo >&2 echo >&2 "ERROR: ${0##*/} requires no input arguments." echo >&2 sed '/^$/q;/^#!/d;s/^# //;s/^#//' $0 >&2 exit 1 fi texfile=$( (ls -t *.tex | head -1) 2>/dev/null ) if [ -n "$texfile" ]; then echo "Processing $texfile ." latex "$texfile" base="${texfile%.tex}" dvifile="${base}.dvi" if [ $make_ps -eq 1 -a "$dvifile" -nt "$texfile" ]; then dvips -o "${base}.ps" "$dvifile" fi if [ $make_pdf -eq 1 -a "$dvifile" -nt "$texfile" ]; then # Check whether the file is a beamer file (requires option -t none # in dvi2pdf) grep \\\\documentclass "$texfile" | grep -E "beamer|tudprosper" > /dev/null 2>&1 if [ $? == 0 ] then dvi2pdf -t none "$dvifile" else dvi2pdf "$dvifile" fi fi else echo "No .tex files found." fi