annotate makeBookeA4.sh @ 257:a3c356207253

Add licence note to website.
author Jim Hague <jim.hague@acm.org>
date Fri, 21 Jun 2013 10:12:24 +0100
parents e8ae4d29b52f
children 7b98278d6e8b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
181
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
1 #!/bin/bash
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
2 #
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
3 # Build the Booke. First assemble the book LaTeX, then build it
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
4 # into a PDF.
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
5 #
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
6 # All EPS and PDF tune graphics must be present already. Run
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
7 # makeGraphics.sh to make these.
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
8 #
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
9
229
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
10 # Restore titles like 'Exploding Potato, The' to the
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
11 # expected 'The Exploding Potato'.
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
12 fixtitle()
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
13 {
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
14 retval=`echo "$1" | sed -e "s/\(.*\), *\(.*\)/\2 \1/"`
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
15 }
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
16
181
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
17 if [ $# != 1 ]; then
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
18 echo "Usage: makeBookeA4.sh <book dir name>"
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
19 exit 1
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
20 fi
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
21
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
22 dir=`pwd`
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
23
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
24 booke=$dir/$1
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
25 builddir=$dir/build
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
26 graphicsdir=$dir/graphics/$1
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
27 output=dottesA4.tex
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
28 outputxdv=${output/%.tex/.xdv}
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
29 outputpdf=${output/%.tex/.pdf}
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
30
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
31 mkdir -p $builddir
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
32
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
33 cp buildno.txt $builddir
248
440172d9f5d6 Redo the printed Booke title page.
Jim Hague <jim.hague@acm.org>
parents: 229
diff changeset
34 cp buzzard.eps $builddir
440172d9f5d6 Redo the printed Booke title page.
Jim Hague <jim.hague@acm.org>
parents: 229
diff changeset
35 if [ -r $booke/title.txt ]; then
440172d9f5d6 Redo the printed Booke title page.
Jim Hague <jim.hague@acm.org>
parents: 229
diff changeset
36 cp $booke/title.txt $builddir
440172d9f5d6 Redo the printed Booke title page.
Jim Hague <jim.hague@acm.org>
parents: 229
diff changeset
37 else
440172d9f5d6 Redo the printed Booke title page.
Jim Hague <jim.hague@acm.org>
parents: 229
diff changeset
38 touch $builddir/title.txt
440172d9f5d6 Redo the printed Booke title page.
Jim Hague <jim.hague@acm.org>
parents: 229
diff changeset
39 fi
181
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
40 if [ -r $booke/subtitle.txt ]; then
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
41 cp $booke/subtitle.txt $builddir
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
42 else
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
43 touch $builddir/subtitle.txt
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
44 fi
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
45 if [ -r $booke/intro.txt ]; then
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
46 cp $booke/intro.txt $builddir
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
47 else
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
48 touch $builddir/intro.txt
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
49 fi
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
50 cp dottes.tex.a4header $builddir/$output
252
4fb2e5728879 Put book intro text into its own file.
Jim Hague <jim.hague@acm.org>
parents: 248
diff changeset
51 cat dottes.tex.intro >> $builddir/$output
181
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
52
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
53 # Now, for each tune, make the tune graphic and add it, inside a
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
54 # centre section, so the document. Then add a TOC entry.
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
55 find $booke -name "*.abc" | sort |
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
56 while read filename
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
57 do
229
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
58 name=`basename $filename .abc`
181
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
59 title=`$dir/abcfield.py --field T --latex $filename`
229
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
60 fixtitle "$title"
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
61 title=$retval
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
62
255
e8ae4d29b52f Move Change: notice closer to the bottom of the tune graphic.
Jim Hague <jim.hague@acm.org>
parents: 254
diff changeset
63 echo -E "\begin{figure}[H]" >> $builddir/$output
181
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
64 echo -E "\phantomsection" >> $builddir/$output
255
e8ae4d29b52f Move Change: notice closer to the bottom of the tune graphic.
Jim Hague <jim.hague@acm.org>
parents: 254
diff changeset
65 echo -E "{\centering \hypertarget{$name}{\includegraphics[width=\textwidth,keepaspectratio]{$graphicsdir/$name}}}" >> $builddir/$output
181
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
66 echo -E "\addcontentsline{toc}{subsection}{$title}" >> $builddir/$output
229
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
67
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
68 changefile=`$dir/abcfield.py --field N $filename | grep "Change:" | sed -e "s/Change: *//"`
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
69 changetitle=""
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
70 if [ -n "$changefile" ]; then
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
71 changetitle=`$dir/abcfield.py --field T --latex $booke/$changefile`
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
72 fixtitle "$changetitle"
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
73 changetitle=$retval
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
74 changename=`basename $changefile .abc`
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
75 echo -E "Change: \hyperlink{$changename}{$changetitle}" >> $builddir/$output
181
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
76 fi
255
e8ae4d29b52f Move Change: notice closer to the bottom of the tune graphic.
Jim Hague <jim.hague@acm.org>
parents: 254
diff changeset
77 echo -E "\end{figure}" >> $builddir/$output
181
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
78 done
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
79
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
80 cat dottes.tex.firstlines >> $builddir/$output
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
81
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
82 find $booke -name "*.abc" | sort |
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
83 while read filename
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
84 do
229
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
85 name=`basename $filename .abc`
181
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
86 title=`$dir/abcfield.py --field T --latex $filename`
229
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
87 fixtitle "$title"
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
88 title=$retval
181
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
89 echo -E "\hyperlink{$name}{$title} & \raisebox{-.25\height}{\includegraphics[width=0.6\textwidth]{$graphicsdir/firstline-$name}} \\\\" >> $builddir/$output
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
90 done
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
91
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
92 cat dottes.tex.footer >> $builddir/$output
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
93
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
94 cd $builddir
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
95
185
9dd24e61d6dd When making A4 book, we don't need to do special A5 handling on Squeeze.
Jim Hague <jim.hague@acm.org>
parents: 181
diff changeset
96 xelatex $output
9dd24e61d6dd When making A4 book, we don't need to do special A5 handling on Squeeze.
Jim Hague <jim.hague@acm.org>
parents: 181
diff changeset
97 xelatex $output
254
bd69673595d0 Run Latex a third time to get the page numbers right.
Jim Hague <jim.hague@acm.org>
parents: 252
diff changeset
98 xelatex $output
181
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
99
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
100 mv $outputpdf $dir/$1-A4.pdf
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
101
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
102 cd $dir