blob: f179bf36a5616da1fd9f07653dec0148c1d8d16d (
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
#!/bin/csh -f
#(ie run the cshell on this but don't read the .cshrc)
# l2: 2002 Nov 12. John Collins.
# l2: 2002 Nov 11. John Collins.
# l2: 2002 Nov 6. John Collins.
# l2: 2002 Nov 5. John Collins. Simplified from l v. 2.17
set myname=l2
set displayErrors = 0
set mainCwd = $cwd
#alias beep '(echo -n ""; sleep 1; echo -n "")'
alias beep '(echo -n "")'
nextarg:
if ( "$1" == "-d" ) then
set displayErrors=1
shift
goto nextarg
endif
if ( "$1" == "-d-" ) then
set displayErrors=0
shift
goto nextarg
endif
if ( ("$1" == "") || ("$1" == "-h") || ("$1" == "--help") ) then
echo "Usage $myname [-d|-d-] paper.tex"
echo ""
echo " -d ==> display errors"
echo " -d- ==> do not display errors (default)"
echo " -h, --help ==> show this message"
exit 0
endif
set paper=$1
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
# 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
beep&
set err = /tmp/`whoami`-$base:t
set tmperr = $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
# latex puts its generated files in the current directory, rather
# than the directory of the source file. So change to the
# temporary directory, and run latex with the path removed from the
# filename argument:
pushd /tmp
latex $err:t
popd
# Give the original latex file a valid dvi file containing the error log.
cp $err.dvi $base.dvi
# Make a dummy aux file. And also make a .aux.bak file. This
# solves the following:
# 1. Sometimes a run with errors results from or has produced
# a bad .aux file. This gets read in on the next run and
# an infinite error loop results unless the .aux file is
# deleted or replaced by something innocuous.
# 2. Latexmk is liable to make extra runs of latex after an
# error is produced. In simple cases, this can be avoided
# if the aux file is later than the tex file and the
# aux.bak file has the same contents.
echo "\relax" > $base.aux
echo "\relax" > $base.aux.bak
rm -f $err.aux $err.log $err.tex
if ( $displayErrors) then
# Popup a new window containing the error log
if ( $emergencyStop ) then
echo xdvi display shows the last page of the errors
set page = '+'
else
set page = ''
endif
xdvi $err.dvi $page &
sleep 2
endif
rm -f $err.dvi
exit 1
# end latexerrors %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
else
echo Successful run
exit 0
endif
|