summaryrefslogtreecommitdiff
path: root/support/latexmk/extra-scripts/l1
blob: cf8d1c4b643800f60b1ddd5c738cec921e58d3fc (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/csh -f
#(ie run the cshell on this but don't read the .cshrc)

clear
echo version = 2.17 of l 2002 Nov 5
# 2002 Nov  5, 2.17: (John Collins) Make work with latexmk
# 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!)

set myname=l1

if ( "$1" == "") then
   set paper=paper
else
   set paper=$1
endif

if ( "$paper:e" == "" ) then
   set base=$paper
   set paper=${base}.tex
else
   set base=$paper:r
endif

if !(-f $paper) then
   echo $paper does not exist\!
   exit 1;
endif

# popcross refreshes the xdvi display by briefly putting
# a window in front of the xdvi window.  This is crude but effective.
# A better way is to use the kickxdvi routine.
set kickxdvi = popcross # old method.
set kickxdvi = kickxdvi

# 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

# determine if there was an error, by looking at paper.log:
grep "! Emergency stop." $base.log
@ EmergencyStop = ($status == 0)
# Also find if no output produced:
#     Examine only the last line of the file to pick out only the
#     message produced by TeX, and not something else with the same
#     string. 
tail -1 $base.log | grep "No pages of output."
@ NoOutput = ($status == 0)

if ($EmergencyStop || $NoOutput)then

   # begin latexerrors %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   echo create and display latex errors

   set err = `whoami`-$base
   set tmperr = /tmp/$err.tex

   echo "\documentclass[12pt]{article}" > $tmperr
   echo "\textwidth 7.5in"  >> $tmperr
   echo "\begin{document}"  >> $tmperr
   if ( $EmergencyStop ) then
        echo "Error(s) in tex file ($paper): " >> $tmperr
   else if ( $NoOutput ) then
        echo "No output from tex file ($paper): " >> $tmperr
   endif
   echo "\begin{verbatim}" >> $tmperr

   cat $base.log >> $tmperr

   echo "\end{verbatim}" >> $tmperr
   echo "\end{document}" >> $tmperr

   pushd /tmp
     latex $err.tex 
     if ( $EmergencyStop ) then
         echo xdvi display shows the last page of the errors
         set page = '+'
     else
         set page = '' 
     endif
     xdvi $err.dvi $page &
   popd
   # end   latexerrors %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   cp /tmp/$err.dvi $base.dvi
   $kickxdvi
   echo "****************************************"
   echo "* ERROR IN PAPER - fix paper.tex file\! *"
   echo "****************************************"
   # beep
   echo -n ""
   sleep 2
   # beep
   echo -n ""
   cd /tmp
   rm -f $err.aux $err.dvi $err.log $err.tex

   exit 1
else
   echo Successful run
   $kickxdvi
   if !(-f done || -d done) then
      mkdir done
   endif
   touch done

   exit

endif