Mercurial > dottes
annotate makeBookeA4.sh @ 263:7b98278d6e8b
Add instrument name into title page for transpositions.
author | Jim Hague <jim.hague@acm.org> |
---|---|
date | Fri, 21 Jun 2013 20:00:54 +0100 |
parents | e8ae4d29b52f |
children | 1d9a6aaba914 |
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 | 10 # Restore titles like 'Exploding Potato, The' to the |
11 # expected 'The Exploding Potato'. | |
12 fixtitle() | |
13 { | |
14 retval=`echo "$1" | sed -e "s/\(.*\), *\(.*\)/\2 \1/"` | |
15 } | |
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 |
263
7b98278d6e8b
Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents:
255
diff
changeset
|
50 rm $builddir/instrument.txt |
7b98278d6e8b
Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents:
255
diff
changeset
|
51 if [ -r $booke/instrument.txt ]; then |
7b98278d6e8b
Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents:
255
diff
changeset
|
52 cp $booke/instrument.txt $builddir |
7b98278d6e8b
Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents:
255
diff
changeset
|
53 else |
7b98278d6e8b
Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents:
255
diff
changeset
|
54 touch $builddir/instrument.txt |
7b98278d6e8b
Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents:
255
diff
changeset
|
55 fi |
181
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
56 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
|
57 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
|
58 |
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
59 # 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
|
60 # 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
|
61 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
|
62 while read filename |
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
63 do |
229 | 64 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
|
65 title=`$dir/abcfield.py --field T --latex $filename` |
229 | 66 fixtitle "$title" |
67 title=$retval | |
68 | |
255
e8ae4d29b52f
Move Change: notice closer to the bottom of the tune graphic.
Jim Hague <jim.hague@acm.org>
parents:
254
diff
changeset
|
69 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
|
70 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
|
71 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
|
72 echo -E "\addcontentsline{toc}{subsection}{$title}" >> $builddir/$output |
229 | 73 |
74 changefile=`$dir/abcfield.py --field N $filename | grep "Change:" | sed -e "s/Change: *//"` | |
75 changetitle="" | |
76 if [ -n "$changefile" ]; then | |
77 changetitle=`$dir/abcfield.py --field T --latex $booke/$changefile` | |
78 fixtitle "$changetitle" | |
79 changetitle=$retval | |
80 changename=`basename $changefile .abc` | |
81 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
|
82 fi |
255
e8ae4d29b52f
Move Change: notice closer to the bottom of the tune graphic.
Jim Hague <jim.hague@acm.org>
parents:
254
diff
changeset
|
83 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
|
84 done |
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
85 |
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
86 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
|
87 |
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
88 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
|
89 while read filename |
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
90 do |
229 | 91 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
|
92 title=`$dir/abcfield.py --field T --latex $filename` |
229 | 93 fixtitle "$title" |
94 title=$retval | |
181
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
95 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
|
96 done |
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
97 |
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
98 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
|
99 |
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
100 cd $builddir |
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
101 |
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
|
102 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
|
103 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
|
104 xelatex $output |
181
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
105 |
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
106 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
|
107 |
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
108 cd $dir |