changeset 266:06e140f48543

Revise scripts for building printed Bookes. A lot of stuff was being duplicated between different page size. Consolidate where possible, and in particular put as much into a single source file (dottes.tex) as possible. Making a single Booke is now potentially quicker, as the tune pages don't necessarily have to be regenerate every time.
author Jim Hague <jim.hague@acm.org>
date Wed, 26 Jun 2013 23:37:45 +0100
parents 3e5335396f48
children 1b08069e5cc4
files docclass.A4.tex docclass.A5.tex docsetup.A4.tex docsetup.A5.tex dottes.tex dottes.tex.a4header dottes.tex.a5header dottes.tex.firstlines dottes.tex.footer dottes.tex.intro makeAll.sh makeBooke.sh makeBookeA4.sh makeBookeA5.sh makeBookeTunePages.sh makeBooklet.sh
diffstat 16 files changed, 320 insertions(+), 460 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docclass.A4.tex	Wed Jun 26 23:37:45 2013 +0100
@@ -0,0 +1,1 @@
+\documentclass[a4paper,11pt]{article}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docclass.A5.tex	Wed Jun 26 23:37:45 2013 +0100
@@ -0,0 +1,1 @@
+\documentclass[a5paper,landscape,11pt]{article}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docsetup.A4.tex	Wed Jun 26 23:37:45 2013 +0100
@@ -0,0 +1,32 @@
+% ----- Page setup
+
+% Adjust margins for A4 portrait. Increase width by 4cm and height by 4cm.
+\addtolength{\textwidth}{4cm}
+\addtolength{\hoffset}{-2cm}
+
+\addtolength{\textheight}{4cm}
+\addtolength{\voffset}{-2cm}
+
+% Move the top margin up a further cm.
+\addtolength{\textheight}{1cm}
+\addtolength{\voffset}{-1cm}
+
+% -----
+
+% Title page
+\newfontfamily\havocfont[Scale=3.5]{English Towne}
+
+\newcommand*{\titleBoD}{\begingroup
+\centering
+{\Large \havocfont{Ye}}\\[\baselineskip]
+{\Huge \havocfont{Crie Havock}}\\[\baselineskip]
+{\Large \havocfont{Booke of}}\\[\baselineskip]
+{\Huge \havocfont{\instrument Dottes}}\\[\baselineskip]
+\vfill
+{\Huge \input{title.txt}}\\[\baselineskip]
+{\Large \input{subtitle.txt}}\\[\baselineskip]
+\vfill
+\includegraphics[width=0.5\textwidth,keepaspectratio]{buzzard}
+\vfill
+{Compiled by Jim Hague}\\
+\endgroup}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docsetup.A5.tex	Wed Jun 26 23:37:45 2013 +0100
@@ -0,0 +1,32 @@
+% ----- Page setup
+
+% Adjust margins for A5 landscape. Increase width by 4cm and height by 4cm.
+\addtolength{\textwidth}{4cm}
+\addtolength{\hoffset}{-2cm}
+
+\addtolength{\textheight}{4cm}
+\addtolength{\voffset}{-2cm}
+
+% Move the top margin up a further cm.
+\addtolength{\textheight}{1cm}
+\addtolength{\voffset}{-1cm}
+
+% -----
+
+% Title page
+\newfontfamily\havocfont[Scale=2.1]{English Towne}
+
+\newcommand*{\titleBoD}{\begingroup
+\centering
+{\Large \havocfont{Ye}}\\[\baselineskip]
+{\Huge \havocfont{Crie Havock}}\\[\baselineskip]
+{\Large \havocfont{Booke of}}\\[\baselineskip]
+{\Huge \havocfont{\instrument Dottes}}\\[\baselineskip]
+\vfill
+{\huge \input{title.txt}}\\%[\baselineskip]
+{\large \input{subtitle.txt}}\\[\baselineskip]
+\vfill
+\includegraphics[width=0.12\textwidth,keepaspectratio]{buzzard}
+\vfill
+{Compiled by Jim Hague}\\
+\endgroup}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dottes.tex	Wed Jun 26 23:37:45 2013 +0100
@@ -0,0 +1,104 @@
+\input{docclass.tex}
+
+\usepackage{fontspec}
+\usepackage{graphicx}
+\usepackage{fancyhdr}
+\usepackage{longtable}
+\usepackage[toc]{multitoc}
+
+\usepackage{hyperref}
+\hypersetup{
+    bookmarks=true,%
+    colorlinks=true,%
+    citecolor=black,%
+    filecolor=black,%
+    linkcolor=black,%
+    urlcolor=black
+}
+
+% ----- Common variables
+
+\def \build {\input{buildno.txt}}
+\def \instrument {\input{instrument.txt}}
+
+% ----- Paper size document setup
+
+\input{docsetup.tex}
+
+% ----- Appearance
+
+\setmainfont{Times New Roman}
+
+% Don't show section numbers.
+\setcounter{secnumdepth}{-1}
+
+% -----
+
+\begin{document}
+
+% ----- Title page
+
+\begin{titlepage}
+\titleBoD
+\end{titlepage}
+
+% ----- Headers and footers
+
+\pagestyle{fancyplain}
+\fancyhf{}
+\lfoot{Issue \build}
+\rfoot{\thepage}
+\renewcommand{\headrulewidth}{0pt}
+
+% ----- Contents
+
+\tableofcontents
+
+% -----
+
+\section{Introduction}
+
+\input{intro.txt}
+
+All tunes in this book are believed to be in the public domain, or at the
+very least enjoy widespread currency on the folk music scene. If I have
+inadvertantly transgressed on anyone's copyright, please contact me at
+\href{mailto:dottes@cryhavoc.org.uk}{\texttt{dottes@cryhavoc.org.uk}} and I will
+remove the offending tune.
+
+Being folk tunes, many of the tunes herein have many variations.
+The music presented here is my attempt at reflecting what the musicians
+of Cry Havoc play. I'm in no way suggesting that they are
+in any way \emph{correct}. This is just how we go about them.
+
+The Booke of Dottes is a constant work in progress. You can download the latest
+version from \url{http://dottes.cryhavoc.org.uk/}.
+
+% -----
+
+\section{Tunes}
+
+Tunes are arranged in alphabetical order of tune title.
+
+\newpage
+
+\input{tunes.tex}
+
+% -----
+
+\newpage
+\section{List of tune first lines}
+
+You know the feeling. Everyone has just launched into a well-loved tune.
+You've heard it before, but don't remember the name. So here's a list of
+tune first lines to help you figure out what it is in time to join in.
+
+\setlength\LTleft{0pt}
+\setlength\LTright{0pt}
+\begin{longtable}{lr}
+\input{firstlines.tex}
+\end{longtable}
+
+% -----
+
+\end{document}
--- a/dottes.tex.a4header	Fri Jun 21 22:28:21 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-\documentclass[a4paper,11pt]{article}
-\usepackage{fontspec}
-\usepackage{graphicx}
-\usepackage{fancyhdr}
-\usepackage{longtable}
-\usepackage[toc]{multitoc}
-
-\usepackage{hyperref}
-\hypersetup{
-    bookmarks=true,%
-    colorlinks=true,%
-    citecolor=black,%
-    filecolor=black,%
-    linkcolor=black,%
-    urlcolor=black
-}
-
-% ----- Common variables
-
-\def \build {\input{buildno.txt}}
-\def \instrument {\input{instrument.txt}}
-
-% ----- Appearance
-
-%\setmainfont{Century Schoolbook L}
-\setmainfont{Times New Roman}
-
-% ----- Page setup
-
-% Adjust margins for A4 portrait. Increase width by 4cm and height by 4cm.
-\addtolength{\textwidth}{4cm}
-\addtolength{\hoffset}{-2cm}
-
-\addtolength{\textheight}{4cm}
-\addtolength{\voffset}{-2cm}
-
-% Move the top margin up a further cm.
-\addtolength{\textheight}{1cm}
-\addtolength{\voffset}{-1cm}
-
-% -----
-
-% Don't show section numbers.
-\setcounter{secnumdepth}{-1}
-
-% -----
-
-% Title page
-\newfontfamily\havocfont[Scale=3.5]{English Towne}
-
-\newcommand*{\titleDB}{\begingroup
-\centering
-{\Large \havocfont{Ye}}\\[\baselineskip]
-{\Huge \havocfont{Crie Havock}}\\[\baselineskip]
-{\Large \havocfont{Booke of}}\\[\baselineskip]
-{\Huge \havocfont{\instrument Dottes}}\\[\baselineskip]
-\vfill
-{\Huge \input{title.txt}}\\[\baselineskip]
-{\Large \input{subtitle.txt}}\\[\baselineskip]
-\vfill
-\includegraphics[width=0.5\textwidth,keepaspectratio]{buzzard}
-\vfill
-{Compiled by Jim Hague}\\
-\endgroup}
-
-% -----
-
-\begin{document}
-
-% ----- Title page
-
-\begin{titlepage}
-\titleDB
-\end{titlepage}
-
-% ----- Headers and footers
-
-\pagestyle{fancyplain}
-\fancyhf{}
-\lfoot{Issue \build}
-\rfoot{\thepage}
-\renewcommand{\headrulewidth}{0pt}
-
-% ----- Contents
-
-\tableofcontents
--- a/dottes.tex.a5header	Fri Jun 21 22:28:21 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-\documentclass[a5paper,landscape,11pt]{article}
-\usepackage{fontspec}
-\usepackage{graphicx}
-\usepackage{fancyhdr}
-\usepackage{longtable}
-\usepackage[toc]{multitoc}
-
-\usepackage{hyperref}
-\hypersetup{
-    bookmarks=true,%
-    colorlinks=true,%
-    citecolor=black,%
-    filecolor=black,%
-    linkcolor=black,%
-    urlcolor=black
-}
-
-% ----- Common variables
-
-\def \build {\input{buildno.txt}}
-\def \instrument {\input{instrument.txt}}
-
-% ----- Appearance
-
-%\setmainfont{Century Schoolbook L}
-\setmainfont{Times New Roman}
-
-% ----- Page setup
-
-% Adjust margins for A5 landscape. Increase width by 4cm and height by 4cm.
-\addtolength{\textwidth}{4cm}
-\addtolength{\hoffset}{-2cm}
-
-\addtolength{\textheight}{4cm}
-\addtolength{\voffset}{-2cm}
-
-% Move the top margin up a further cm.
-\addtolength{\textheight}{1cm}
-\addtolength{\voffset}{-1cm}
-
-% -----
-
-% Don't show section numbers.
-\setcounter{secnumdepth}{-1}
-
-% -----
-
-% Title page
-\newfontfamily\havocfont[Scale=2.1]{English Towne}
-
-\newcommand*{\titleDB}{\begingroup
-\centering
-{\Large \havocfont{Ye}}\\[\baselineskip]
-{\Huge \havocfont{Crie Havock}}\\[\baselineskip]
-{\Large \havocfont{Booke of}}\\[\baselineskip]
-{\Huge \havocfont{\instrument Dottes}}\\[\baselineskip]
-\vfill
-{\huge \input{title.txt}}\\%[\baselineskip]
-{\large \input{subtitle.txt}}\\[\baselineskip]
-\vfill
-\includegraphics[width=0.12\textwidth,keepaspectratio]{buzzard}
-\vfill
-{Compiled by Jim Hague}\\
-\endgroup}
-
-% -----
-
-\begin{document}
-
-% ----- Title page
-
-\begin{titlepage}
-\pagestyle{empty}
-\titleDB
-\end{titlepage}
-
-% ----- Headers and footers
-
-\pagestyle{fancyplain}
-\fancyhf{}
-\lfoot{Issue \build}
-\rfoot{\thepage}
-\renewcommand{\headrulewidth}{0pt}
-
-% ----- Contents
-
-\tableofcontents
-
-\newpage
--- a/dottes.tex.firstlines	Fri Jun 21 22:28:21 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-% -----
-
-\newpage
-\section{List of tune first lines}
-
-You know the feeling. Everyone has just launched into a well-loved tune.
-You've heard it before, but don't remember the name. So here's a list of
-tune first lines to help you figure out what it is in time to join in.
-
-\setlength\LTleft{0pt}
-\setlength\LTright{0pt}
-\begin{longtable}{lr}
--- a/dottes.tex.footer	Fri Jun 21 22:28:21 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-\end{longtable}
-
-% -----
-
-\end{document}
--- a/dottes.tex.intro	Fri Jun 21 22:28:21 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-% -----
-
-\section{Introduction}
-
-\input{intro.txt}
-
-All tunes in this book are believed to be in the public domain, or at the
-very least enjoy widespread currency on the folk music scene. If I have
-inadvertantly transgressed on anyone's copyright, please contact me at
-\href{mailto:dottes@cryhavoc.org.uk}{\texttt{dottes@cryhavoc.org.uk}} and I will
-remove the offending tune.
-
-Being folk tunes, many of the tunes herein have many variations.
-The music presented here is my attempt at reflecting what the musicians
-of Cry Havoc play. I'm in no way suggesting that they are
-in any way \emph{correct}. This is just how we go about them.
-
-The Booke of Dottes is a constant work in progress. You can download the latest
-version from \url{http://dottes.cryhavoc.org.uk/}.
-
-% -----
-
-\section{Tunes}
-
-Tunes are arranged in alphabetical order of tune title.
-
-\newpage
--- a/makeAll.sh	Fri Jun 21 22:28:21 2013 +0100
+++ b/makeAll.sh	Wed Jun 26 23:37:45 2013 +0100
@@ -10,8 +10,10 @@
 makeABooke()
 {
     ./makeGraphics.sh "$1"
-    ./makeBookeA5.sh "$1"
-    ./makeBookeA4.sh "$1"
+    ./makeBookeTunePages.sh "$1"
+    ./makeBooke.sh "$1" A4
+    ./makeBooke.sh "$1" A5
+    ./makeBooklet.sh "$1"
     ./makeWebGraphics.sh "$1"
     ./makeWebAudio.sh "$1"
     ./makeWeb.sh "$1" "$1" "$2"
@@ -20,8 +22,10 @@
 makeATransposedBooke()
 {
     ./makeGraphics.sh "$1"
-    ./makeBookeA5.sh "$1"
-    ./makeBookeA4.sh "$1"
+    ./makeBookeTunePages.sh "$1"
+    ./makeBooke.sh "$1" A4
+    ./makeBooke.sh "$1" A5
+    ./makeBooklet.sh "$1"
     ./makeWebGraphics.sh "$1"
     ./makeWeb.sh "$1" "$2" "$3"
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/makeBooke.sh	Wed Jun 26 23:37:45 2013 +0100
@@ -0,0 +1,53 @@
+#!/bin/bash
+#
+# Build the Booke. Move subfiles into place and build the Booke into a PDF.
+#
+# The Booke tune content and all EPS and PDF tune graphics must be
+# present already. Run makeGraphics.sh first and then
+# makeBookeTunePages.sh.
+#
+
+if [ $# != 2 ]; then
+    echo "Usage: makeBooke.sh <book dir name> <A4|A5>"
+    exit 1
+fi
+
+dir=`pwd`
+
+booke=$dir/$1
+papersize=$2
+builddir=$dir/build
+graphicsdir=$dir/graphics/$1
+booketex=$dir/dottes.tex
+bookepdf=$builddir/dottes.pdf
+
+mkdir -p $builddir
+
+cp dottes.tex $builddir
+cp buildno.txt $builddir
+cp buzzard.eps $builddir
+for item in title subtitle intro instrument
+do
+    rm -f $builddir/$item.txt
+    if [ -r $booke/$item.txt ]; then
+        cp $booke/$item.txt $builddir
+    else
+        touch $builddir/$item.txt
+    fi
+done
+
+for filename in $dir/*.${papersize}.tex
+do
+    name=`basename $filename .${papersize}.tex`
+    cp $filename $builddir/$name.tex
+done
+
+cd $builddir
+
+xelatex $booketex
+xelatex $booketex
+xelatex $booketex
+
+mv $bookepdf $dir/$1-${papersize}.pdf
+
+cd $dir
--- a/makeBookeA4.sh	Fri Jun 21 22:28:21 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-#!/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
--- a/makeBookeA5.sh	Fri Jun 21 22:28:21 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-#!/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: makeBookeA5.sh <book dir name>"
-    exit 1
-fi
-
-dir=`pwd`
-
-booke=$dir/$1
-builddir=$dir/build
-graphicsdir=$dir/graphics/$1
-output=dottesA5.tex
-outputxdv=${output/%.tex/.xdv}
-outputpdf=${output/%.tex/.pdf}
-outputa4=dottesA5onA4booklet.tex
-outputa4pdf=dottesA5onA4booklet.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.a5header $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,height=0.85\textheight,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
-
-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.
-#
-# And, sigh, this fails on Sid. The first page comes out as A4 portrait.
-# So try to work out which we are using and run the appropriate command.
-ver=`xetex -version | head -n 1`
-ver=${ver/*TeX Live /}
-ver=${ver/\/*/}
-if [ "$ver" == "2009" ]; then
-    xelatex -no-pdf $output
-    xelatex -no-pdf $output
-    xelatex -no-pdf $output
-    xdvipdfmx -p a5 -l $outputxdv
-else
-    xelatex $output
-    xelatex $output
-    xelatex $output
-fi
-xelatex $outputa4
-
-mv $outputpdf $dir/$1-A5.pdf
-mv $outputa4pdf $dir/${1}-A5bookletA4.pdf
-
-cd $dir
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/makeBookeTunePages.sh	Wed Jun 26 23:37:45 2013 +0100
@@ -0,0 +1,62 @@
+#!/bin/bash
+#
+# Generate the LaTeX for the Booke tune pages (tunes.tex) and the index
+# of first lines (firstlines.tex). These are generated into the build
+# directory.
+#
+# 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: makeBookeTunePages.sh <book dir name>"
+    exit 1
+fi
+
+dir=`pwd`
+
+booke=$dir/$1
+builddir=$dir/build
+graphicsdir=$dir/graphics/$1
+tunesoutput=$builddir/tunes.tex
+indexoutput=$builddir/firstlines.tex
+
+mkdir -p $builddir
+
+rm -f $tunesoutput $indexoutput
+
+# 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}" >> $tunesoutput
+        echo -E "\phantomsection" >> $tunesoutput
+        echo -E "\hypertarget{$name}{\includegraphics[width=\textwidth,height=0.85\textheight,keepaspectratio]{$graphicsdir/$name}}" >> $tunesoutput
+        echo -E "\addcontentsline{toc}{subsection}{$title}" >> $tunesoutput
+        echo -E "\end{center}" >> $tunesoutput
+
+        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}" >> $tunesoutput
+        fi
+
+        echo -E "\hyperlink{$name}{$title} & \raisebox{-.25\height}{\includegraphics[width=0.6\textwidth]{$graphicsdir/firstline-$name}} \\\\" >> $indexoutput
+    done
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/makeBooklet.sh	Wed Jun 26 23:37:45 2013 +0100
@@ -0,0 +1,27 @@
+#!/bin/bash
+#
+# Assuming the existance of the A5 PDF of the given Booke, produce the
+# A4 booklet-that-prints-as-A5.
+#
+
+if [ $# != 1 ]; then
+    echo "Usage: makeBookelet.sh <book dir name>"
+    exit 1
+fi
+
+dir=`pwd`
+
+builddir=$dir/build
+
+booke=$1-A5.pdf
+# This assumes dottesA5.pdf as input.
+booklet=$dir/dottesA5onA4booklet.tex
+bookletpdf=$builddir/dottesA5onA4booklet.pdf
+
+mkdir -p $builddir
+
+cp $booke $builddir/dottesA5.pdf
+
+cd $builddir
+xelatex $booklet
+mv $bookletpdf $dir/${1}-A5bookletA4.pdf