view makeBooke.sh @ 119:15ce1ecb5ba3

Fix page size issue on xetex on Squeeze. The version of xetex on Squeeze does not pass the paper size through to the PDF rendered properly. Following a Googled suggestion, split the rendering into two part, and pass the page size explicitly to the PDF generation. This isn't necessary for the booklet because the output is A4 portrait, the default paper size.
author Jim Hague <jim.hague@acm.org>
date Fri, 13 Apr 2012 15:57:02 +0100
parents 8f3b50ede59c
children 4b0025be9d22
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.
#

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

dir=`pwd`

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

mkdir -p $builddir

cp buildno.txt $builddir
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
cp dottes.tex.header $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
        title=`$dir/abctitle.py --latex $filename`
        name=`basename $filename .abc`
        echo -E "\begin{center}" >> $builddir/$output
        echo -E "\phantomsection" >> $builddir/$output
        echo -E "\hypertarget{$name}{\includegraphics[width=\textwidth,height=0.9\textheight,keepaspectratio]{$graphicsdir/$name}}" >> $builddir/$output
        echo -E "\addcontentsline{toc}{subsection}{$title}" >> $builddir/$output
        echo -E "\end{center}" >> $builddir/$output
    done

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

find $booke -name "*.abc" | sort |
    while read filename
    do
        title=`$dir/abctitle.py --latex $filename`
        name=`basename $filename .abc`
        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

cp $outputa4 $builddir

cd $builddir

# The version of xetex on Squeeze doesn't do pass the A5 landscape instruction
# down to the PDF generator. So split out and do manually.
xelatex -no-pdf $output
xelatex -no-pdf $output
xdvipdfmx -p a5 -l $outputxdv
xelatex $outputa4

mv $outputpdf $dir/$1.pdf
mv $outputa4pdf $dir/${1}-booklet.pdf

cd $dir