view makeBookeA4.sh @ 264:1d9a6aaba914

Revert attempt at getting Change: notices closer to music in print. My previous attempt appeared to work, but didn't actually centre graphics if the graphic was less than page width. Revert, and instead add a \vfill before the tune to leave more blank space between multiples tunes on a page, It's more obvious then which tune the change belongs to. Not idea, but the best I can do for now.
author Jim Hague <jim.hague@acm.org>
date Fri, 21 Jun 2013 21:20:18 +0100
parents 7b98278d6e8b
children
line wrap: on
line source

#!/bin/bash
#
# Build the Booke. First assemble the book LaTeX, then build it
# into a PDF.
#
# All EPS and PDF tune graphics must be present already. Run
# makeGraphics.sh to make these.
#

# Restore titles like 'Exploding Potato, The' to the
# expected 'The Exploding Potato'.
fixtitle()
{
    retval=`echo "$1" | sed -e "s/\(.*\), *\(.*\)/\2 \1/"`
}

if [ $# != 1 ]; then
    echo "Usage: makeBookeA4.sh <book dir name>"
    exit 1
fi

dir=`pwd`

booke=$dir/$1
builddir=$dir/build
graphicsdir=$dir/graphics/$1
output=dottesA4.tex
outputxdv=${output/%.tex/.xdv}
outputpdf=${output/%.tex/.pdf}

mkdir -p $builddir

cp buildno.txt $builddir
cp buzzard.eps $builddir
if [ -r $booke/title.txt ]; then
    cp $booke/title.txt $builddir
else
    touch $builddir/title.txt
fi
if [ -r $booke/subtitle.txt ]; then
    cp $booke/subtitle.txt $builddir
else
    touch $builddir/subtitle.txt
fi
if [ -r $booke/intro.txt ]; then
    cp $booke/intro.txt $builddir
else
    touch $builddir/intro.txt
fi
rm $builddir/instrument.txt
if [ -r $booke/instrument.txt ]; then
    cp $booke/instrument.txt $builddir
else
    touch $builddir/instrument.txt
fi
cp dottes.tex.a4header $builddir/$output
cat dottes.tex.intro >> $builddir/$output

# Now, for each tune, make the tune graphic and add it, inside a
# centre section, so the document. Then add a TOC entry.
find $booke -name "*.abc" | sort |
    while read filename
    do
        name=`basename $filename .abc`
        title=`$dir/abcfield.py --field T --latex $filename`
        fixtitle "$title"
        title=$retval

        echo -E "\vfill \begin{center}" >> $builddir/$output
        echo -E "\phantomsection" >> $builddir/$output
        echo -E "\hypertarget{$name}{\includegraphics[width=\textwidth,keepaspectratio]{$graphicsdir/$name}}" >> $builddir/$output
        echo -E "\addcontentsline{toc}{subsection}{$title}" >> $builddir/$output
        echo -E "\end{center}" >> $builddir/$output

        changefile=`$dir/abcfield.py --field N $filename | grep "Change:" | sed -e "s/Change: *//"`
        changetitle=""
        if [ -n "$changefile" ]; then
            changetitle=`$dir/abcfield.py --field T --latex $booke/$changefile`
            fixtitle "$changetitle"
            changetitle=$retval
            changename=`basename $changefile .abc`
            echo -E "Change: \hyperlink{$changename}{$changetitle}" >> $builddir/$output
        fi
    done

cat dottes.tex.firstlines >> $builddir/$output

find $booke -name "*.abc" | sort |
    while read filename
    do
        name=`basename $filename .abc`
        title=`$dir/abcfield.py --field T --latex $filename`
        fixtitle "$title"
        title=$retval
        echo -E "\hyperlink{$name}{$title} & \raisebox{-.25\height}{\includegraphics[width=0.6\textwidth]{$graphicsdir/firstline-$name}} \\\\" >> $builddir/$output
    done

cat dottes.tex.footer >> $builddir/$output

cd $builddir

xelatex $output
xelatex $output
xelatex $output

mv $outputpdf $dir/$1-A4.pdf

cd $dir