%%
%% LilyPond titling for LaTeX
%%
%% Note
%%
%%    Defining a value, but leaving it empty:
%%        \def\lilypondfoo{}
%%    makes LaTeX break on the \\ in:
%%        \ifx\lilypondfoo\undefined\else{\lilypondfoo\\}\fi
%%
\def\makelilypondtitle
{
  \begin{center}
        \bfseries
        \ifx\lilypondtitle\undefined\else{\huge\lilypondtitle\\}\fi
        \ifx\lilypondsubtitle\undefined\else{\Large\lilypondsubtitle\\}\fi
        \ifx\lilypondsubsubtitle\undefined\else{\large\lilypondsubsubtitle\\}\fi
  \end{center}
  \bigskip
  % urg
  \edef\saveparskip{\parskip}\parskip-5mm
  \begin{minipage}[t]{0.45\textwidth}
        \ifx\lilypondpoet\undefined\else{\lilypondpoet\\}\fi
        \ifx\lilypondmeter\undefined\else{\lilypondmeter\\}\fi
  \end{minipage}\hspace*{\fill}
  \begin{minipage}[t]{0.45\textwidth}
      \begin{flushright}
          \ifx\lilypondcomposer\undefined\else{\large\normalfont\scshape\lilypondcomposer\\}\fi
          \ifx\lilypondopus\undefined\else{\lilypondopus\\}\fi
          \ifx\lilypondarranger\undefined\else{\lilypondarranger\\}\fi
        \end{flushright}%
  \end{minipage}\par
  \parskip\saveparskip
  \ifx\lilypondinstrument\undefined\else{\center{\large\lilypondinstrument}\par}\fi
  \ifx\lilypondpiece\undefined\else{\flushleft{\large\normalfont\scshape\lilypondpiece}\par}\fi
%  \leavevmode
  \global\let\lilypondopus\relax%
  \global\let\lilypondpiece\relax%
  \global\let\mustmakelilypondtitle\undefined%
}
%
\def\makelilypondpiecetitle
{
  \bigskip\myfilbreak
  \ifx\lilypondopus\undefined\else{\flushright{\lilypondopus}\par}\fi
  \ifx\lilypondpiece\undefined\else{\flushleft{\large\normalfont\scshape\lilypondpiece}\par}\fi
  \nopagebreak%
  \global\let\lilypondopus\relax%
  \global\let\lilypondpiece\relax%
  \global\let\mustmakelilypondpiecetitle\undefined%
}
% header -- head ?
% these names can't be changed: they're uses in mutopia headers
\def\theheader
{
  \ifx\lilypondhead\undefined\else%
    \parbox{\textwidth}{\mbox{}\lilypondhead}\fi
}
\def\thefooter
{
  \ifx\lilypondfooter\undefined\else%
    \parbox{\textwidth}{\mbox{}\lilypondfooter}\fi
}
\endinput

