3
# Author: Jody Klymak <jklymak@apl.washington.edu>, publisted by a posting
4
# to the pdftex mailinglist.
6
# recursively finds all your eps files. Looks down \input{fname}.
8
# 1) cannot handle \input{fname} split over more than one line.
9
# 1.5) cannot handle multiple \input{} or \includegraphics{} on one line.
10
# 2) Must be run from same directory as the Latex file.
11
# 3) Does not look down $TEXINPUTS or anything fancy like that...
12
# 4) Handling of \include is untested (though I guess its trivial)
13
# 5) Assumes *all* your graphics inclusions are [e]ps. But don't
14
# fret, because if they are not epstopdf dies anyhow....
15
# 6) Does not distinguish between percent (\%) and comment (%).
18
# 20030103 -- Lachlan Andrew <lha@users.sourceforge.net>
19
# * Only append '.tex' if $fname doesn't exist.
20
# * Correctly handle lines with '}' after the \includegraphics{}
21
# * Allow multiple extensions for graphics files. .eps -> .ps -> none
22
# (Should try them in the same order as \includegraphics does
23
# -- given by \DeclareGraphicsExtensions{}?)
24
# * Allow \include the same way as \input
25
# * Allow \includegraphics{} to be split over multiple lines
26
# * Check that commands begin with '\', and allow spaces before arguments
28
# EDIT these two lines for your system....
30
$Eps2PdfCom = "epstopdf";
31
$ThisFunCom = "e2pall";
35
# check for a *.tex at the end...
36
if ((-f "$fname")=="" && $fname !~ /.tex$/){
37
$fname = "$fname.tex";
40
open(TEXFILE,$fname) or die "Cannot open file $fname";
41
# print "Finding *.eps files in $fname\n";
44
while($line=<TEXFILE>){
45
# truncate $line after % sign....
47
# check for /input....
48
if ($line=~/\\input *{([^}]*)}/){
49
print `$ThisFunCom $1`;
51
# check for /include....
52
if ($line=~/\\include *{([^}]*)}/){
53
print `$ThisFunCom $1`;
57
if ($line=~/\\includegraphics.*{([^}]*)}/){
60
elsif ($seekingArg==1 && ($line=~/{([^}]*)}/)){
63
elsif ($line=~/\\includegraphics/){
69
if ((-f "$base.eps")!="") {
70
$srcfile = "$base.eps";
72
elsif ((-f "$base.ps")!=""){
73
$srcfile = "$base.ps";
78
# check that the [e]ps version is newer than the pdf version....
79
if ((-M "$base.pdf")=="" || (-M "$base.pdf") >= (-M "$srcfile")){
80
print "Constructing \t $base.pdf from $srcfile\n";
81
print `$Eps2PdfCom $srcfile`;
84
print "$base.pdf \t is up to date with $srcfile\n";