#!/bin/csh -f #(ie run the cshell on this but don't read the .cshrc) echo version = 2.39 of l 2010 Mar 08 # 2010 Mar 08, 2.38: remove creation of done directory - not used # 2009 Nov 10, 2.37: spell LOSING correctly # 2009 Jul 19, 2.36: when error, give the paper.log # 2009 Jul 11, 2.35: focus on Terminal after pdf display in OSX # 2009 Jul 11, 2.34: don't display empty pdf # 2009 Jul 11, 2.33: on MacOSX (Darwin) make pdf with time tag in /tmp # 2006 Dec 21, 2.32: error in Emergency stop detection # 2006 Dec 11, 2.31: write error location to file # 2006 Oct 09, 2.30: remove sleep in front of kickxdvi # 2006 Feb 10, 2.29: clean documentation a bit # 2005 Dec 12, 2.28: fix # on Mar 21 note. # 2005 Apr 18, 2.27: kickxdvi only once avoids killing xdvi? # 2005 Mar 22, 2.26: finish removing lockfile # 2005 Mar 21, 2.25: LaTeX.lock is a pain. Only turn on if there is a # -lock argument # 2004 Jun 29, 2.24: add 1 second of sleep before xrefresh to avoid # blowing xdvi away? this did not help # 2004 Feb 6, 2.23: LaTeX.lock mechanism - remove lock if no paper.tex # 2003 Nov 17, 2.22: LaTeX.lock mechanism - work with errors # 2003 Nov 16, 2.21: LaTeX.lock mechanism # 2003 Nov 4, 2.20: replace popcross with xrefresh! # 2003 Jan 25, 2.19: no clear at start # 2002 Oct 30, 2.18: return to /dev/null and popcross! # 2002 Oct 30, 2.17: replace cat /dev/null with -interaction=nonstopmode # 2002 Oct 21, 2.16: replace popcross with kickxdvi # 2000 Mar 6, 2.14: done is created as a directory (more useful than a file) # 1999 Nov 18: removal of a paper triggers bibtex call now # 1999 Aug 19: when done, `touch done` so that other # programs can be triggered (ie latex2html!) echo Run laTeX on paper.tex # Dr. Thomas D. Schneider # National Institutes of Health # National Cancer Institute # Center for Cancer Research Nanobiology Program # Molecular Information Theory Group # Frederick, Maryland 21702-1201 # toms@ncifcrf.gov # permanent email: toms@alum.mit.edu (use only if first address fails) # http://www.ccrnp.ncifcrf.gov/~toms/ # The l script runs LaTeX on the paper.tex in the current directory. # If there are undefined citations, BibTeX is also run and LaTeX # rerun. This automates the calling of LaTex. Further automation # is done by the atp script and atchange. See: # http://www.lecb.ncifcrf.gov/~toms/atchange.html # The l script uses topostscript to automatically convert from # paper.dvi to paper.ps, a postscript version of the paper. The user # can then run ps2pdf to create a PDF if desired. # The l script uses a locking mechanism to prevent two copies from # running at the same time. set beep = "" # the name of the paper: set paper = "paper" # the location in the paper of an error found: set paperline = "$paper.lin" # locking mechanism: LOCK set dolock = false if ($#argv > 0) then if ("$1" == '-lock') then set doloc = true endif endif if ($dolock == true) then set lockfile = LaTeX.lock if (-f $lockfile) then echo "The l script is already running in this directory\!" echo `pwd` echo `ls $lockfile` echo "If this is in error, remove the file $lockfile" echo "and l will proceed to run LaTeX." rm -i $lockfile if (-f $lockfile) then echo "Ok, l is shutting down." exit else echo "$lockfile is gone, l is continuing." endif endif # if the lock was removed, make a new one. if !(-f $lockfile) then echo "$lockfile" > $lockfile echo "The l script is running." >> $lockfile echo `date` >> $lockfile endif else set lockfile = "/dummy-file-name-for-lockfile-mechanism" endif if !(-f $paper.tex) then echo $paper.tex does not exist\! # make a beep sound: echo -n "$beep" # locking mechanism: UNLOCK if (-f $lockfile) then rm -f $lockfile endif exit endif # This script has to have a mechanism to update the xdvi display of # the paper. The original solution was 'popcross', a script that # would put up a cross consisting of two thin windows (or, later, just # a single horizontal window and then removing them. This would # triggger xdvi to referesh, but it is an ugly solution. The simple # solution is to use the Xwindows refresh function. The method has # been tested under Gnome. It is a great final solution! set kickxdvi = xrefresh # You can replace refresh with setxdvi when one has a modern xdvi! # set overfull = Overfull set overfull = NoOverfull echo ALL $overfull MESSAGES WILL BE SUPPRESSED # see Lamport page 177 for dealing with overfull boxes. # basically, do this: # \documentclass[12pt,draft]{article} # draft will mark the overfull boxes and the solution # will become obvious... # run latex. The cat /dev/null prevents # latex from stopping. Errors are reported to paper.log cat /dev/null | latex $paper | grep -v $overfull # 2002 Oct 30: A cleaner way to do this: # latex paper -interaction=nonstopmode | grep -v $overfull # THIS DOES NOT POP UP THE ERROR DISPLAY!!! # 2006 Dec 11: eliminate the okrun file. # determine if there was an error, by looking at paper.log: #set okrun = /tmp/`whoami`.paper.okrun #grep "Emergency stop" paper.log |\ #wc -l | sed -e "s/ //g" > $okrun # #if (`cat $okrun` == 0) then if ("`grep 'Emergency stop' ${paper}.log`" == '') then echo test if bibtex call is needed # The warning we watch for is like: # LaTeX Warning: # Citation `Lin.Riggs1975' on page 13 undefined on input line 1381 set tmp = /tmp/`whoami`.paper.bibtest grep "LaTeX Warning: Citation" $paper.log |\ grep "undefined" $paper.log |\ wc -l | sed -e "s/ //g" > $tmp # cat $tmp if (`cat $tmp` == 0) then echo references ok else echo "NEW REFERENCE CITATION: calling BiBTeX\!" # show current status $kickxdvi & bibtex $paper cat /dev/null | latex $paper | grep -v $overfull cat /dev/null | latex $paper | grep -v $overfull endif # 1999 Nov 18 # The method above does not detect *removal* of a paper # we can detect this as a difference between the # number of \citation{ and \bibcite{ lines in paper.aux: set citation = `grep "\citation{" $paper.aux | wc -l` set bibcite = `grep "\bibcite{" $paper.aux | wc -l` if !($citation == bibcite) then echo "LOSING REFERENCE CITATION: calling BiBTeX\!" bibtex $paper cat /dev/null | latex $paper | grep -v $overfull cat /dev/null | latex $paper | grep -v $overfull endif $kickxdvi & # 2010 Mar 08 Remove creation of 'done' directory # if !(-f done || -d done) then # mkdir done # endif # touch done topostscript $paper echo -n "$beep" if (`uname` == "Darwin") then # is $paper.ps empty? if (`head -1 $paper.ps | wc -l` == 0) then echo "empty $paper.ps file" exit endif ps2pdf $paper.ps set timetag = `date "+%Y%b%d-%H-%M-%S"` echo pdf time tag is $timetag set tmppdf = /tmp/`whoami`${timetag}.pdf echo pdf with time tag is $tmppdf cp $paper.pdf $tmppdf open $tmppdf # focus back on the terminal open "/Applications/Utilities/Terminal.app" endif rm -f $tmp else # begin latexerrors %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% echo ERROR FOUND # example error line: # l.113 } set error = "`grep '^l\.' $paper.log | tail -1`" echo $error set line = `echo $error| tr -dc "[:digit:]"` echo at line $line # errors are recorded as NEGATIVE error lines echo "-$line" > $paperline echo create and display latex errors set err = `whoami`-paper set tmperr = /tmp/$err.tex echo "\documentstyle[12pt]{article}" > $tmperr echo "\begin{document}" >> $tmperr #echo "zzz" >> $tmperr echo "\begin{verbatim}" >> $tmperr cat paper.log >> $tmperr echo "\end{verbatim}" >> $tmperr echo "\end{document}" >> $tmperr pushd /tmp latex $err.tex echo xdvi display shows the last page of the errors set page = '' xdvi $err.dvi +$page & echo $tmperr ========================= echo $err ========================= popd # end latexerrors %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% echo > paper.dvi $kickxdvi & echo "****************************************" set error = "* ERROR IN PAPER - fix paper.tex file\! *" echo "$error" echo cat paper.log # new as of 2009 jul 19 echo # echo "$error" echo "************* $error ***************************" # beep echo -n "$beep" sleep 2 # beep echo -n "$beep" pushd /tmp rm -f $err.aux $err.dvi $err.log $err.tex popd endif # rm -f $okrun if ($dolock == true) then # locking mechanism: UNLOCK if (-f $lockfile) then rm -f $lockfile else echo "l script: Something is wrong, there was no $lockfile $beep" endif endif