-
Notifications
You must be signed in to change notification settings - Fork 4
/
texdep
executable file
·119 lines (100 loc) · 1.83 KB
/
texdep
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
#! /bin/sh
#
# Determine the dependencies of a *.tex Tex/Latex source file. Used by
# Jérôme Kunegis for compiling papers.
#
# INVOCATION
# $0 FILENAME
#
# STDOUT
# List of dependencies, one file per line
#
# ENVIRONMENT
# $TEXDEP_GRAPHICSEXT (optional) extension of included graphics,
# without the dot; defaults to "pdf"
#
# ABOUT
# (c) 2015-2017 Written by Jérôme Kunegis <[email protected]>
#
file="$1"
[ "$file" ] || {
echo >&2 '*** Missing filename'
echo >&2 "Invocation: $0 FILENAME"
exit 1
}
[ -e "$file" ] || {
echo >&2 "*** $0: Cannot read file '$file'"
exit 1
}
if [ -z "$TEXDEP_GRAPHICSEXT" ] ; then
graphicsext=pdf
else
graphicsext="$TEXDEP_GRAPHICSEXT"
fi
#
# The file itself
#
echo "$file"
#
# Bibtex source files
#
<"$file" sed -E -e '
/\\bibliography\{/!d;
s,^[^{]*\{([^}]*).*$,\1,' |
tr ',' '
' |
sed -E -e 's,$,.bib,'
#
# Bibliography style file
#
<"$file" sed -E -e '
s,^.*\\bibliographystyle\{(.+)\}.*$,\1.bst,
t
d
' | while IFS= read -r filename ; do
[ -e "$filename" ] && echo "$filename"
done
#
# Plots
#
<"$file" sed -E -e '
/^\s*%/d
s,^.*(\\includegraphics|\\begin\{overpic\})[^{]*\{([^}]+)\}.*$,\2,
t
d
' |
while IFS= read name ; do
# Empty name
if [ -z "$name" ] ; then
continue
fi
# Add extension only if there is not already one
if echo "$name" | grep -qvE '\.(pdf|png|eps|jpg)$' ; then
name="$name.$graphicsext"
fi
echo "$name"
done
#
# Other included .tex files
#
<"$file" sed -E -e '
s,^[^%]*\\(input|include)([^a-zA-Z0-9].*)?\{([^}]+)\}.*$,\3,
t
d' |
while IFS= read -r name ; do
if [ -z "$name" ] ; then
continue
fi
if echo "$name" | grep -qvE '\.tex$' ; then
name="$name.tex"
fi
"$0" "$name"
## echo "$name"
done
#
# CLS files
#
<"$file" sed -E -e '/\\documentclass\{/!d;s,^.*\\documentclass\{(.*)\}.*$,\1,;/article/d' |
while IFS= read -r name ; do
echo "$name.cls"
done