-
Notifications
You must be signed in to change notification settings - Fork 1
/
latexBuild
executable file
·118 lines (103 loc) · 1.85 KB
/
latexBuild
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
#!/bin/bash
BUILD="latex"
LAST=""
UPLOAD="KO"
UP_DIR=""
TEX=""
PDF=""
FLAG=""
for PARAM in $@
do
case $PARAM in
-f)
LAST="file"
;;
-h|--help)
echo display this window
exit
;;
-b)
LAST="build"
;;
-fb)
LAST="fullBuild"
;;
-gu)
UPLOAD="OK"
LAST="google_upload"
;;
*)
case $LAST in
google_upload)
if [ "$UP_DIR" != "" ]; then
echo $UP_DIR will be replaced by $PARAM
echo $PARAM wil be the next google drive upload directory
fi
UP_DIR=$PARAM
;;
file)
TEX="$TEX $PARAM"
;;
build)
BUILD=$PARAM$BUILD
;;
fullBuild)
BUILD=$PARAM
;;
*)
echo unknow param $PARAM
;;
esac
;;
esac
done
echo "$BUILD" ; sleep 1
if [ "$TEX" == "" ]; then
TEX=$(find . | grep -E "*.tex$")
fi
for DOC in $TEX
do
for img in $(find . | grep -E "\.(png|jpg|jpeg|bmp)$")
do
out="$(echo $img | rev | cut -d'.' -f2- | rev).eps"
printf "%-30s -> %s\n" $img $out
[ ! -e $out ] && convert $img eps2:$out
done
echo $DOC
BASE=$( echo $DOC | rev | cut -d '.' -f 2- | rev )
PS=$BASE".ps"
PDF=$BASE".pdf"
DVI=$BASE".dvi"
AUX=$BASE".aux"
FLAG=$( [ "$(grep minted $DOC)" != "" ] && echo "-shell-escape" || echo "" )
# first compilation
$BUILD $FLAG $DOC
RET_1=$?
# generate the bib element if needed
if [ "$RET_1" == 0 ];
then
bibtex $AUX
RET_2=$?
fi
# second compilation if no bib or first if bib exist
if [ "$RET_1" == 0 ];
then
$BUILD $FLAG $DOC
RET=$?
fi
# second compilation if bib exist
if [ "$RET" == 0 ] && [ "$RET_2" == 0 ];
then
$BUILD $FLAG $DOC
RET=$?
fi
# second compilation if bib exist
if [ "$RET" == 0 ] && [ -f $DVI ];
then
dvips $DVI -o $PS
ps2pdf $PS $PDF
RET=$?
fi
[ "$RET" == 0 ] && echo -e "\e[1;32mall done perfectly\e[0m"
[ "$RET" == 0 ] && [ "$UPLOAD" == "OK" ] && google_upload $PDF $UP_DIR
done