Move tune and first line inclusion code into macros.

Also use tune title, not name, as hyperlink targets. This removes the need to pass
the name into the macros.
This commit is contained in:
Jim Hague 2013-07-12 11:36:14 +01:00
parent 7bf24bc921
commit 8554e9e664
2 changed files with 39 additions and 12 deletions

View File

@ -7,7 +7,7 @@
\usepackage{fancyhdr} \usepackage{fancyhdr}
\usepackage{longtable} \usepackage{longtable}
\usepackage[UKenglish]{babel} \usepackage[UKenglish]{babel}
\usepackage[UKenglish]{isodate} %\usepackage[UKenglish]{isodate}
% Non-indented paragraphs with space between them. % Non-indented paragraphs with space between them.
\usepackage{parskip} \usepackage{parskip}
@ -27,12 +27,46 @@
% ----- Common variables % ----- Common variables
\def \build {\input{buildno.txt}} \newcommand{\build}{\input{buildno.txt}}
\def \instrument {\input{instrument.txt}} \newcommand{\instrument}{\input{instrument.txt}}
% Havoc purple is #9900cc. % Havoc purple is #9900cc.
\definecolor{havocpurple}{rgb}{0.597,0,0.797} \definecolor{havocpurple}{rgb}{0.597,0,0.797}
% ----- Macros
\makeatletter
\def\ifemptyarg#1{%
\if\relax\detokenize{#1}\relax % H. Oberdiek
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi}
\makeatother
% Show the main tune graphic and optional change.
% Args are change title (optional), tune title, tune graphic filename.
\newcommand{\showtune}[3][]{%
\vfill
\begin{center}
\phantomsection
\hypertarget{#2}{%
\includegraphics[width=\textwidth,height=0.85\textheight,keepaspectratio]{#3}
}
\addcontentsline{toc}{section}{#2}
\end{center}
\ifemptyarg{#1}{}{%
Change: \hyperlink{#1}{#1}
}%
}
% Show the tune first line. Generate table row.
% Args are the tune title and the first line graphic filename.
\newcommand{\showfirstline}[2]{%
\hyperlink{#1}{#1} & %
\raisebox{-.25\height}{\includegraphics[width=0.65\textwidth,height=1.3cm]{#2}} \\
}
% ----- Paper size document setup % ----- Paper size document setup
\input{docsetup.tex} \input{docsetup.tex}

View File

@ -42,21 +42,14 @@ find $booke -name "*.abc" | sort |
fixtitle "$title" fixtitle "$title"
title=$retval 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}{section}{$title}" >> $tunesoutput
echo -E "\end{center}" >> $tunesoutput
changefile=`$dir/abcfield.py --field N $filename | grep "Change:" | sed -e "s/Change: *//"` changefile=`$dir/abcfield.py --field N $filename | grep "Change:" | sed -e "s/Change: *//"`
changetitle="" changetitle=""
if [ -n "$changefile" ]; then if [ -n "$changefile" ]; then
changetitle=`$dir/abcfield.py --field T --latex $booke/$changefile` changetitle=`$dir/abcfield.py --field T --latex $booke/$changefile`
fixtitle "$changetitle" fixtitle "$changetitle"
changetitle=$retval changetitle=$retval
changename=`basename $changefile .abc`
echo -E "Change: \hyperlink{$changename}{$changetitle}" >> $tunesoutput
fi fi
echo -E "\showtune[$changetitle]{$title}{$graphicsdir/$name}" >> $tunesoutput
echo -E "\hyperlink{$name}{$title} & \raisebox{-.25\height}{\includegraphics[width=0.65\textwidth,height=1.3cm]{$graphicsdir/firstline-$name}} \\\\" >> $indexoutput echo -E "\showfirstline{$title}{$graphicsdir/firstline-$name}" >> $indexoutput
done done