comparison makeBookeA5.sh @ 181:6a0bdabfb255

Add a A4 portrait book with multiple tunes per page. Also add a script to make all variants of a single book, and look for <tune name>.tex files, and if one exists add it after the tune.
author Jim Hague <jim.hague@acm.org>
date Sat, 26 Jan 2013 13:47:01 +0000
parents makeBooke.sh@295ba8275ab4
children 1e4443d58177
comparison
equal deleted inserted replaced
180:3acc7c6ba9fc 181:6a0bdabfb255
1 #!/bin/bash
2 #
3 # Build the Booke. First assemble the book LaTeX, then build it
4 # into a PDF.
5 #
6 # All EPS and PDF tune graphics must be present already. Run
7 # makeGraphics.sh to make these.
8 #
9
10 if [ $# != 1 ]; then
11 echo "Usage: makeBookeA5.sh <book dir name>"
12 exit 1
13 fi
14
15 dir=`pwd`
16
17 booke=$dir/$1
18 builddir=$dir/build
19 graphicsdir=$dir/graphics/$1
20 output=dottesA5.tex
21 outputxdv=${output/%.tex/.xdv}
22 outputpdf=${output/%.tex/.pdf}
23 outputa4=dottesA5onA4booklet.tex
24 outputa4pdf=dottesA5onA4booklet.pdf
25
26 mkdir -p $builddir
27
28 cp buildno.txt $builddir
29 if [ -r $booke/subtitle.txt ]; then
30 cp $booke/subtitle.txt $builddir
31 else
32 touch $builddir/subtitle.txt
33 fi
34 if [ -r $booke/intro.txt ]; then
35 cp $booke/intro.txt $builddir
36 else
37 touch $builddir/intro.txt
38 fi
39 cp dottes.tex.a5header $builddir/$output
40
41 # Now, for each tune, make the tune graphic and add it, inside a
42 # centre section, so the document. Then add a TOC entry.
43 find $booke -name "*.abc" | sort |
44 while read filename
45 do
46 title=`$dir/abcfield.py --field T --latex $filename`
47 name=`basename $filename .abc`
48 echo -E "\newpage" >> $builddir/$output
49 echo -E "\begin{center}" >> $builddir/$output
50 echo -E "\phantomsection" >> $builddir/$output
51 echo -E "\hypertarget{$name}{\includegraphics[width=\textwidth,height=0.9\textheight,keepaspectratio]{$graphicsdir/$name}}" >> $builddir/$output
52 echo -E "\addcontentsline{toc}{subsection}{$title}" >> $builddir/$output
53 echo -E "\end{center}" >> $builddir/$output
54 text=$booke/$name.tex
55 if [ -r $text ]; then
56 cat $text >> $builddir/$output
57 fi
58 done
59
60 cat dottes.tex.firstlines >> $builddir/$output
61
62 find $booke -name "*.abc" | sort |
63 while read filename
64 do
65 title=`$dir/abcfield.py --field T --latex $filename`
66 name=`basename $filename .abc`
67 echo -E "\hyperlink{$name}{$title} & \raisebox{-.25\height}{\includegraphics[width=0.6\textwidth]{$graphicsdir/firstline-$name}} \\\\" >> $builddir/$output
68 done
69
70 cat dottes.tex.footer >> $builddir/$output
71
72 cp $outputa4 $builddir
73
74 cd $builddir
75
76 # The version of xetex on Squeeze doesn't do pass the A5 landscape instruction
77 # down to the PDF generator. So split out and do manually.
78 #
79 # And, sigh, this fails on Sid. The first page comes out as A4 portrait.
80 # So try to work out which we are using and run the appropriate command.
81 ver=`xetex -version | head -n 1`
82 ver=${ver/*TeX Live /}
83 ver=${ver/\/*/}
84 if [ "$ver" == "2009" ]; then
85 xelatex -no-pdf $output
86 xelatex -no-pdf $output
87 xdvipdfmx -p a5 -l $outputxdv
88 else
89 xelatex $output
90 xelatex $output
91 fi
92 xelatex $outputa4
93
94 mv $outputpdf $dir/$1-A5.pdf
95 mv $outputa4pdf $dir/${1}-A5bookletA4.pdf
96
97 cd $dir