# HG changeset patch
# User Jim Hague <jim.hague@laicatc.com>
# Date 1330783721 0
# Node ID 01c4d873153f7dba6fac8c58a55624126bd6e61a
# Parent  72b5d67756e1c334ba21b2a13b514d19ea0f1462
Quick attempt to parameterise different book builds.

Move subtitle and intro text into book directory.
Do all building in build directory.
Name output by the book name.

diff -r 72b5d67756e1 -r 01c4d873153f Session/intro.tex
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Session/intro.tex	Sat Mar 03 14:08:41 2012 +0000
@@ -0,0 +1,2 @@
+This book provides the dots for all tunes commonly played at Cry Havoc music
+sessions.
diff -r 72b5d67756e1 -r 01c4d873153f Session/subtitle.tex
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Session/subtitle.tex	Sat Mar 03 14:08:41 2012 +0000
@@ -0,0 +1,1 @@
+Music commonly played at Cry Havoc sessions
diff -r 72b5d67756e1 -r 01c4d873153f dottes.tex.header
--- a/dottes.tex.header	Sat Mar 03 12:00:35 2012 +0000
+++ b/dottes.tex.header	Sat Mar 03 14:08:41 2012 +0000
@@ -16,9 +16,9 @@
 
 \begin{document}
 
-\title{Ye Crie Havock Booke of Dottes}
+\title{Ye Crie Havock Booke of Dottes \\ \input{subtitle.tex}}
 
-\author{Jim Hague}
+\author{Cry Havoc}
 
 \date{\today}
 
@@ -34,8 +34,7 @@
 
 \section{Introduction}
 
-This book provides the dots for all tunes commonly played at Cry Havoc music
-sessions.
+\input{intro.tex}
 
 % -----
 
diff -r 72b5d67756e1 -r 01c4d873153f dottesona4.tex
--- a/dottesona4.tex	Sat Mar 03 12:00:35 2012 +0000
+++ b/dottesona4.tex	Sat Mar 03 14:08:41 2012 +0000
@@ -10,5 +10,5 @@
 \usepackage{ifpdf,ifxetex}
 
 \begin{document}
-\includepdf[pages=-, nup=1x2, booklet=true]{build/dottes.pdf}
+\includepdf[pages=-, nup=1x2, booklet=true]{dottes.pdf}
 \end{document}
diff -r 72b5d67756e1 -r 01c4d873153f makeBooke.sh
--- a/makeBooke.sh	Sat Mar 03 12:00:35 2012 +0000
+++ b/makeBooke.sh	Sat Mar 03 14:08:41 2012 +0000
@@ -5,7 +5,7 @@
 #
 
 if [ $# != 1 ]; then
-    echo "Usage: make.sh <book dir name>"
+    echo "Usage: makeBooke.sh <book dir name>"
     exit 1
 fi
 
@@ -14,25 +14,38 @@
 booke=$dir/$1
 builddir=$dir/build
 output=dottes.tex
+outputpdf=dottes.pdf
+outputa4=dottesona4.tex
+outputa4pdf=dottesona4.pdf
 
 mkdir -p $builddir
 
+cp buildno $builddir
+if [ -r $booke/subtitle.tex ]; then
+    cp $booke/subtitle.tex $builddir
+else
+    touch $builddir/subtitle.tex
+fi
+if [ -r $booke/intro.tex ]; then
+    cp $booke/intro.tex $builddir
+else
+    touch $builddir/intro.tex
+fi
 cp dottes.tex.header $builddir/$output
 
-# Now, for each tune, add
-#
-# \addcontentsline{toc}{subsection}{<Tune title>}
-# \begin{abc}[name=<filename>]
-# ... ABC ...
-# \end{abc}
-
+# 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=`grep "^T:" $filename | head -1 | sed -e "s/^T: *//"`
         name=`basename $filename .abc`
         abcm2ps -j0 +c -n -E -O $builddir/$name.eps $filename
-        epstopdf --outfile=$builddir/$name.pdf $builddir/${name}001.eps
+        # Make $name.eps so we can build with LaTeX.
+        mv $builddir/${name}001.eps $builddir/${name}.eps
+        # And make the corresponding PDF for pdflatex.
+        epstopdf --outfile=$builddir/$name.pdf $builddir/${name}.eps
+
         echo -E "\begin{center}" >> $builddir/$output
         echo -E "\includegraphics[width=\textwidth]{$name}" >> $builddir/$output
         echo -E "\addcontentsline{toc}{subsection}{$title}" >> $builddir/$output
@@ -41,9 +54,14 @@
 
 cat dottes.tex.footer >> $builddir/$output
 
+cp $outputa4 $builddir
+
 cd $builddir
 pdflatex $output
 pdflatex $output
+pdflatex $outputa4
+
+mv $outputpdf $dir/$1.pdf
+mv $outputa4 $dir/${1}-booklet.pdf
 
 cd $dir
-pdflatex dottesona4.tex