-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·94 lines (81 loc) · 2.37 KB
/
build.sh
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
#!/bin/sh
# Generates a complete .zip file with templates in German and English as well
# as all example title pages (all possible colors).
# Note: This takes quite a long time due to the amount of processed TeX
# documents.
# Command line arguments:
# $1: the LaTeX engine used for compilation (lualatex or xelatex);
# optional (default: lualatex)
texdir=tex
fontdir=tex/fonts
zipname=latex_wwu_titlepage_$(date +%F)
latex_engine=$1
case "$latex_engine" in
lualatex|xelatex)
;;
'')
latex_engine=lualatex
;;
*)
echo "Invalid LaTeX engine (must be lualatex or xelatex): $latex_engine"
exit 2
;;
esac
if [ ! -f "$fontdir/MetaOffcPro-Bold.ttf" ] || \
[ ! -f "$fontdir/MetaOffcPro-Norm.ttf" ] || \
[ ! -f "$fontdir/MetaOffcPro-NormIta.ttf" ] || \
[ ! -f "$fontdir/MetaScOffcPro-Bold.ttf" ] || \
[ ! -f "$fontdir/MetaScOffcPro-Norm.ttf" ] || \
[ ! -f "$fontdir/MetaScOffcPro-NormIta.ttf" ]; then
echo "Font files missing in $fontdir/!"
exit 1
fi
# clean up previous build
rm -rf "$zipname/"
olddir="$PWD"
tempdir=$(mktemp -d /tmp/latex-beamer.XXXXXX)
cp -r "$texdir/" "$tempdir/"
cd $tempdir
# delete dummy file
find "$fontdir/" -type f ! -name '*.ttf' -delete
# set up directories for compilation of example PDFs
mkdir -p de/vorlage/
mkdir -p en/template/
cp -r "$fontdir/" "$texdir/wwustyle/" \
"$texdir"/*.sty \
"$texdir/titelseite.tex" \
'de/vorlage/'
cp -r "$fontdir/" "$texdir/wwustyle/" \
"$texdir"/*.sty \
"$texdir/titlepage.tex" \
'en/template/'
cp -r de/vorlage/ de/beispiele/
mv de/beispiele/titelseite.tex de/beispiele/titlepage.tex
cp -r en/template/ en/examples/
rm -r "$texdir/"
# compile examples
for d in de/beispiele en/examples; do
cd "$d/"
# generate all color options
for color in black7 234 7462 312 315 3135 369 390; do
options="pantone$color"
# remove commas from file names
filename=$(echo "${options}" | sed 's/,/_/g')
cp titlepage.tex "$filename.tex"
# set options in the TeX file
sed -i "s/pantone312]/$options]/" "$filename.tex"
# run compilations
latexmk "-$latex_engine" -interaction=nonstopmode -silent \
"$filename.tex"
done
# remove source files
rm -r $(basename "$fontdir/") wwustyle/ *.tex *.sty
# remove auxiliary files
rm *.aux *.log *.out *.toc *.fls *.fdb_latexmk *.synctex.gz
cd "$tempdir"
done
# create .zip file
cd "$olddir"
cp -r "$tempdir/" "$zipname"
zip -r "$zipname.zip" "$zipname/"
rm -r "$tempdir"