Mercurial > dottes
annotate makeBookeA5.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 | b8c711dafce1 |
children | 1d9a6aaba914 |
rev | line source |
---|---|
37
72b5d67756e1
Fix up troubles with \. echo -E disables expansion.
Jim Hague <jim.hague@laicatc.com>
parents:
34
diff
changeset
|
1 #!/bin/bash |
13 | 2 # |
3 # Build the Booke. First assemble the book LaTeX, then build it | |
4 # into a PDF. | |
5 # | |
42
0e7d2830cb8b
Put making tune graphics required by web and book into separate dir and make separately.
Jim Hague <jim.hague@laicatc.com>
parents:
40
diff
changeset
|
6 # All EPS and PDF tune graphics must be present already. Run |
0e7d2830cb8b
Put making tune graphics required by web and book into separate dir and make separately.
Jim Hague <jim.hague@laicatc.com>
parents:
40
diff
changeset
|
7 # makeGraphics.sh to make these. |
0e7d2830cb8b
Put making tune graphics required by web and book into separate dir and make separately.
Jim Hague <jim.hague@laicatc.com>
parents:
40
diff
changeset
|
8 # |
0 | 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 | |
0 | 17 if [ $# != 1 ]; then |
181
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
122
diff
changeset
|
18 echo "Usage: makeBookeA5.sh <book dir name>" |
0 | 19 exit 1 |
20 fi | |
21 | |
16 | 22 dir=`pwd` |
23 | |
24 booke=$dir/$1 | |
25 builddir=$dir/build | |
42
0e7d2830cb8b
Put making tune graphics required by web and book into separate dir and make separately.
Jim Hague <jim.hague@laicatc.com>
parents:
40
diff
changeset
|
26 graphicsdir=$dir/graphics/$1 |
181
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
122
diff
changeset
|
27 output=dottesA5.tex |
119
15ce1ecb5ba3
Fix page size issue on xetex on Squeeze.
Jim Hague <jim.hague@acm.org>
parents:
118
diff
changeset
|
28 outputxdv=${output/%.tex/.xdv} |
15ce1ecb5ba3
Fix page size issue on xetex on Squeeze.
Jim Hague <jim.hague@acm.org>
parents:
118
diff
changeset
|
29 outputpdf=${output/%.tex/.pdf} |
181
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
122
diff
changeset
|
30 outputa4=dottesA5onA4booklet.tex |
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
122
diff
changeset
|
31 outputa4pdf=dottesA5onA4booklet.pdf |
0 | 32 |
16 | 33 mkdir -p $builddir |
34 | |
40
93955def7313
Revise page footers, and add build number.
Jim Hague <jim.hague@laicatc.com>
parents:
39
diff
changeset
|
35 cp buildno.txt $builddir |
248
440172d9f5d6
Redo the printed Booke title page.
Jim Hague <jim.hague@acm.org>
parents:
229
diff
changeset
|
36 cp buzzard.eps $builddir |
440172d9f5d6
Redo the printed Booke title page.
Jim Hague <jim.hague@acm.org>
parents:
229
diff
changeset
|
37 if [ -r $booke/title.txt ]; then |
440172d9f5d6
Redo the printed Booke title page.
Jim Hague <jim.hague@acm.org>
parents:
229
diff
changeset
|
38 cp $booke/title.txt $builddir |
440172d9f5d6
Redo the printed Booke title page.
Jim Hague <jim.hague@acm.org>
parents:
229
diff
changeset
|
39 else |
440172d9f5d6
Redo the printed Booke title page.
Jim Hague <jim.hague@acm.org>
parents:
229
diff
changeset
|
40 touch $builddir/title.txt |
440172d9f5d6
Redo the printed Booke title page.
Jim Hague <jim.hague@acm.org>
parents:
229
diff
changeset
|
41 fi |
39
9681f6cd9c2b
Change subtitle and intro files to .txt extension.
Jim Hague <jim.hague@laicatc.com>
parents:
38
diff
changeset
|
42 if [ -r $booke/subtitle.txt ]; then |
9681f6cd9c2b
Change subtitle and intro files to .txt extension.
Jim Hague <jim.hague@laicatc.com>
parents:
38
diff
changeset
|
43 cp $booke/subtitle.txt $builddir |
38
01c4d873153f
Quick attempt to parameterise different book builds.
Jim Hague <jim.hague@laicatc.com>
parents:
37
diff
changeset
|
44 else |
39
9681f6cd9c2b
Change subtitle and intro files to .txt extension.
Jim Hague <jim.hague@laicatc.com>
parents:
38
diff
changeset
|
45 touch $builddir/subtitle.txt |
38
01c4d873153f
Quick attempt to parameterise different book builds.
Jim Hague <jim.hague@laicatc.com>
parents:
37
diff
changeset
|
46 fi |
39
9681f6cd9c2b
Change subtitle and intro files to .txt extension.
Jim Hague <jim.hague@laicatc.com>
parents:
38
diff
changeset
|
47 if [ -r $booke/intro.txt ]; then |
9681f6cd9c2b
Change subtitle and intro files to .txt extension.
Jim Hague <jim.hague@laicatc.com>
parents:
38
diff
changeset
|
48 cp $booke/intro.txt $builddir |
38
01c4d873153f
Quick attempt to parameterise different book builds.
Jim Hague <jim.hague@laicatc.com>
parents:
37
diff
changeset
|
49 else |
39
9681f6cd9c2b
Change subtitle and intro files to .txt extension.
Jim Hague <jim.hague@laicatc.com>
parents:
38
diff
changeset
|
50 touch $builddir/intro.txt |
38
01c4d873153f
Quick attempt to parameterise different book builds.
Jim Hague <jim.hague@laicatc.com>
parents:
37
diff
changeset
|
51 fi |
263
7b98278d6e8b
Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents:
262
diff
changeset
|
52 rm $builddir/instrument.txt |
7b98278d6e8b
Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents:
262
diff
changeset
|
53 if [ -r $booke/instrument.txt ]; then |
7b98278d6e8b
Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents:
262
diff
changeset
|
54 cp $booke/instrument.txt $builddir |
7b98278d6e8b
Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents:
262
diff
changeset
|
55 else |
7b98278d6e8b
Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents:
262
diff
changeset
|
56 touch $builddir/instrument.txt |
7b98278d6e8b
Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents:
262
diff
changeset
|
57 fi |
181
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
122
diff
changeset
|
58 cp dottes.tex.a5header $builddir/$output |
252
4fb2e5728879
Put book intro text into its own file.
Jim Hague <jim.hague@acm.org>
parents:
248
diff
changeset
|
59 cat dottes.tex.intro >> $builddir/$output |
13 | 60 |
38
01c4d873153f
Quick attempt to parameterise different book builds.
Jim Hague <jim.hague@laicatc.com>
parents:
37
diff
changeset
|
61 # Now, for each tune, make the tune graphic and add it, inside a |
01c4d873153f
Quick attempt to parameterise different book builds.
Jim Hague <jim.hague@laicatc.com>
parents:
37
diff
changeset
|
62 # centre section, so the document. Then add a TOC entry. |
13 | 63 find $booke -name "*.abc" | sort | |
64 while read filename | |
65 do | |
229 | 66 name=`basename $filename .abc` |
122
295ba8275ab4
Make output larger where possible.
Jim Hague <jim.hague@laicatc.com>
parents:
120
diff
changeset
|
67 title=`$dir/abcfield.py --field T --latex $filename` |
229 | 68 fixtitle "$title" |
69 title=$retval | |
70 | |
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 "\begin{figure}[H]" >> $builddir/$output |
115
c4efe8b5eea1
Add internal hyperlinks to the book.
Jim Hague <jim.hague@acm.org>
parents:
110
diff
changeset
|
72 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
|
73 echo -E "{\centering \hypertarget{$name}{\includegraphics[width=\textwidth,height=0.85\textheight,keepaspectratio]{$graphicsdir/$name}}}" >> $builddir/$output |
37
72b5d67756e1
Fix up troubles with \. echo -E disables expansion.
Jim Hague <jim.hague@laicatc.com>
parents:
34
diff
changeset
|
74 echo -E "\addcontentsline{toc}{subsection}{$title}" >> $builddir/$output |
229 | 75 |
76 changefile=`$dir/abcfield.py --field N $filename | grep "Change:" | sed -e "s/Change: *//"` | |
77 changetitle="" | |
78 if [ -n "$changefile" ]; then | |
79 changetitle=`$dir/abcfield.py --field T --latex $booke/$changefile` | |
80 fixtitle "$changetitle" | |
81 changetitle=$retval | |
82 changename=`basename $changefile .abc` | |
83 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:
122
diff
changeset
|
84 fi |
255
e8ae4d29b52f
Move Change: notice closer to the bottom of the tune graphic.
Jim Hague <jim.hague@acm.org>
parents:
254
diff
changeset
|
85 echo -E "\end{figure}" >> $builddir/$output |
13 | 86 done |
87 | |
50
e666306c5ab1
Add list of tune first lines.
Jim Hague <jim.hague@laicatc.com>
parents:
42
diff
changeset
|
88 cat dottes.tex.firstlines >> $builddir/$output |
e666306c5ab1
Add list of tune first lines.
Jim Hague <jim.hague@laicatc.com>
parents:
42
diff
changeset
|
89 |
e666306c5ab1
Add list of tune first lines.
Jim Hague <jim.hague@laicatc.com>
parents:
42
diff
changeset
|
90 find $booke -name "*.abc" | sort | |
e666306c5ab1
Add list of tune first lines.
Jim Hague <jim.hague@laicatc.com>
parents:
42
diff
changeset
|
91 while read filename |
e666306c5ab1
Add list of tune first lines.
Jim Hague <jim.hague@laicatc.com>
parents:
42
diff
changeset
|
92 do |
229 | 93 name=`basename $filename .abc` |
122
295ba8275ab4
Make output larger where possible.
Jim Hague <jim.hague@laicatc.com>
parents:
120
diff
changeset
|
94 title=`$dir/abcfield.py --field T --latex $filename` |
229 | 95 fixtitle "$title" |
96 title=$retval | |
115
c4efe8b5eea1
Add internal hyperlinks to the book.
Jim Hague <jim.hague@acm.org>
parents:
110
diff
changeset
|
97 echo -E "\hyperlink{$name}{$title} & \raisebox{-.25\height}{\includegraphics[width=0.6\textwidth]{$graphicsdir/firstline-$name}} \\\\" >> $builddir/$output |
50
e666306c5ab1
Add list of tune first lines.
Jim Hague <jim.hague@laicatc.com>
parents:
42
diff
changeset
|
98 done |
e666306c5ab1
Add list of tune first lines.
Jim Hague <jim.hague@laicatc.com>
parents:
42
diff
changeset
|
99 |
16 | 100 cat dottes.tex.footer >> $builddir/$output |
13 | 101 |
38
01c4d873153f
Quick attempt to parameterise different book builds.
Jim Hague <jim.hague@laicatc.com>
parents:
37
diff
changeset
|
102 cp $outputa4 $builddir |
01c4d873153f
Quick attempt to parameterise different book builds.
Jim Hague <jim.hague@laicatc.com>
parents:
37
diff
changeset
|
103 |
16 | 104 cd $builddir |
119
15ce1ecb5ba3
Fix page size issue on xetex on Squeeze.
Jim Hague <jim.hague@acm.org>
parents:
118
diff
changeset
|
105 |
15ce1ecb5ba3
Fix page size issue on xetex on Squeeze.
Jim Hague <jim.hague@acm.org>
parents:
118
diff
changeset
|
106 # The version of xetex on Squeeze doesn't do pass the A5 landscape instruction |
15ce1ecb5ba3
Fix page size issue on xetex on Squeeze.
Jim Hague <jim.hague@acm.org>
parents:
118
diff
changeset
|
107 # down to the PDF generator. So split out and do manually. |
120
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
108 # |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
109 # And, sigh, this fails on Sid. The first page comes out as A4 portrait. |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
110 # So try to work out which we are using and run the appropriate command. |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
111 ver=`xetex -version | head -n 1` |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
112 ver=${ver/*TeX Live /} |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
113 ver=${ver/\/*/} |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
114 if [ "$ver" == "2009" ]; then |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
115 xelatex -no-pdf $output |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
116 xelatex -no-pdf $output |
254
bd69673595d0
Run Latex a third time to get the page numbers right.
Jim Hague <jim.hague@acm.org>
parents:
252
diff
changeset
|
117 xelatex -no-pdf $output |
120
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
118 xdvipdfmx -p a5 -l $outputxdv |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
119 else |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
120 xelatex $output |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
121 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
|
122 xelatex $output |
120
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
123 fi |
118
8f3b50ede59c
Switch to XeTeX to render. Opens up random OpenType fonts and UTF-8.
Jim Hague <jim.hague@acm.org>
parents:
116
diff
changeset
|
124 xelatex $outputa4 |
38
01c4d873153f
Quick attempt to parameterise different book builds.
Jim Hague <jim.hague@laicatc.com>
parents:
37
diff
changeset
|
125 |
181
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
122
diff
changeset
|
126 mv $outputpdf $dir/$1-A5.pdf |
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
122
diff
changeset
|
127 mv $outputa4pdf $dir/${1}-A5bookletA4.pdf |
21
b61b090cd4c7
Produce an A4 PDF document with the A5 pages in booklet form.
Jim Hague <jim.hague@acm.org>
parents:
16
diff
changeset
|
128 |
b61b090cd4c7
Produce an A4 PDF document with the A5 pages in booklet form.
Jim Hague <jim.hague@acm.org>
parents:
16
diff
changeset
|
129 cd $dir |