#!/bin/csh -f # With no arguments, run latex on the entire book; with one or more # chapter-name arguments, process the selected chapters. # # Usage examples: # # clr approximation shortest-paths # do two selected chapters # clr a*.tex # similar # clr -draft approximation # draft mode, one chapter # clr -cm book # entire book, CM fonts # clr -cm # same as above # clr -cmmath approximation # Times text fonts, CM math fonts # clr -times approximation # Use Times text fonts, Mathtime math fonts umask 002 # Process the options (must all occur at the beginning of the arg list) echo -n "" > book.tex unset mathtime # following is fix by William Ang 3/15/00 to allow large Tex compilation # The environment variable CLRS_MIT must be set to get this (on solaris only, I think) if ($?CLRS_MIT) then set texprog = /m/big-teTeX-0.4/bin/sparc-solaris2.6/latex setenv TEXFORMATS /m/big-teTeX-0.4/texmf/web2c setenv TEXINPUTS /usr/local/pkg/teTeX/texmf//:. source /a/clr/New/tex/config.csh else set texprog = latex endif while ( "$1" =~ -* ) set option=$1; shift switch ( "$option" ) case -cmm*: echo "\PassOptionsToClass{cmmath}{clr}" >> book.tex breaksw case -cm*: echo "\PassOptionsToClass{cmfonts}{clr}" >> book.tex breaksw case -draft: # "global option" mechanism doesn't work when passing options this # way, need to send "draft" to the package explicitly. echo "\PassOptionsToClass{draft}{clr}" >> book.tex echo "\PassOptionsToPackage{draft}{windex}" >> book.tex breaksw case -times: # The "-times" font option does not require anything in the .cfg # file set mathtime=true breaksw case -wl: echo "\RequirePackage{warnless}\relax" >> book.tex breaksw default: echo "Unrecognized option: "'"'"$option"'"' breaksw endsw end # Need to deal with the possibility of MathTime bold fonts not installed # yet: if ($?mathtime) then # if ( ! -f MTMIB.vf ) then # echo "" # echo "Warning: File MTMIB.vf not found for MathTime bold italic;" # echo "Falling back to cmmib (Computer Modern bold italic)." # echo "" # echo "\PassOptionsToClass{cmbold}{clr}" >> book.tex # endif echo "\PassOptionsToClass{mtbold}{clr}" >> book.tex endif # If no chapter names were given, do the whole book if ( $#argv == 0 || "$1" == "book" ) then set argv=book unset include_one else set include_one=true endif set success_msg="<:Successful LaTeX run:>" set mainbreak="========================================================================" set subbreak="------------------------------------------------------------" foreach file ( $* ) echo $mainbreak set base=$file:r cp -p $base.aux{,-save} if ( $?include_one ) then echo "\includeonly{$base}" | cat - book.master >> book.tex $texprog book cp -p book.log $base.log; cp -p book.dvi $base.dvi cp -p book.idx $base.idx grep "$success_msg" book.log >/dev/null if ( $status == 0 ) then echo $subbreak # windex/windex-$MACHTYPE $base else # Copy back the old .aux file unless the latex run completed successfully echo "Restoring old .aux file" cp -p $base.aux{-save,} endif else cp book.master book.tex $texprog book ; echo $subbreak grep "$success_msg" book.log >/dev/null \ || ( echo "Restoring old .aux file"; cp -p book.aux{-save,} ) bibtex book ; echo $subbreak ## latex book ; echo $subbreak # windex/windex-$MACHTYPE book ; echo $subbreak mv book.index index.tex ## latex book ## rm *.toc endif end exit