annotate makeBookeA4.sh @ 241:3524e3b007bb

Revise chords to some that make sense on a guitar. Also remove unplayed [2 at the end of the A tune.
author Jim Hague <jim.hague@acm.org>
date Thu, 06 Jun 2013 20:58:14 +0100
parents 1e4443d58177
children 440172d9f5d6
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
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
34 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
35 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
36 else
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
37 touch $builddir/subtitle.txt
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
38 fi
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
39 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
40 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
41 else
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
42 touch $builddir/intro.txt
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
43 fi
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
44 cp dottes.tex.a4header $builddir/$output
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
45
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
46 # 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
47 # 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
48 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
49 while read filename
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
50 do
229
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
51 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
52 title=`$dir/abcfield.py --field T --latex $filename`
229
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
53 fixtitle "$title"
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
54 title=$retval
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
55
181
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
56 echo -E "\begin{center}" >> $builddir/$output
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
57 echo -E "\phantomsection" >> $builddir/$output
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
58 echo -E "\hypertarget{$name}{\includegraphics[width=\textwidth,keepaspectratio]{$graphicsdir/$name}}" >> $builddir/$output
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
59 echo -E "\addcontentsline{toc}{subsection}{$title}" >> $builddir/$output
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
60 echo -E "\end{center}" >> $builddir/$output
229
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
61
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
62 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
63 changetitle=""
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
64 if [ -n "$changefile" ]; then
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
65 changetitle=`$dir/abcfield.py --field T --latex $booke/$changefile`
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
66 fixtitle "$changetitle"
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
67 changetitle=$retval
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
68 changename=`basename $changefile .abc`
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
69 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
70 fi
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
71 done
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
72
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
73 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
74
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
75 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
76 while read filename
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
77 do
229
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
78 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
79 title=`$dir/abcfield.py --field T --latex $filename`
229
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
80 fixtitle "$title"
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 185
diff changeset
81 title=$retval
181
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
82 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
83 done
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
84
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
85 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
86
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
87 cd $builddir
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
88
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
89 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
90 xelatex $output
181
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 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
93
6a0bdabfb255 Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
94 cd $dir