- {
- % either plain TeX or texinfo or not at the beginning of LaTeX input
- \def\x{\endgroup}
- }
- {
- % provide a proper LaTeX preamble (for A4 paper format)
- \def\x{
- \endgroup
- \def\lilyponddocument{}
- \documentclass[a4paper]{article}
- \pagestyle{empty}
- % \begin is defined as \outer in texinfo, thus we use \csname
- \csname begin\endcsname{document}
- % center staves horizontally on page
- \ifdim\lilypondpaperlinewidth\lilypondpaperunit > 0pt
+ {%% Either plain TeX or texinfo or not at the beginning of LaTeX input.
+ \def\x{
+ \endgroup
+
+ \def\lilypondfontencoding####1{
+ \lilypondECencoding}
+ \def\lilypondpagebreak{
+ \eject}
+ \def\lilypondnopagebreak{
+ \ifvmode
+ \penalty 10000\relax
+ \fi}}}
+
+ {%% LaTeX mode: Provide a complete preamble.
+ \def\x{
+ \endgroup
+
+ %% Indicate that we shall emit `\end{document}' while executing
+ %% \lilypondend.
+ \def\lilyponddocument{}
+
+ \def\lilypondfontencoding####1{
+ \fontencoding{####1}
+ \selectfont}
+ \def\lilypondpagebreak{
+ \newpage}
+ \def\lilypondnopagebreak{
+ \nopagebreak}
+
+ \documentclass[\lilyponddocumentclassoptions]{article}
+
+ %% As a safety guard, don't produce auxiliary files.
+ \nofiles
+
+ %% FIXME: workaround non-existent TeX.def.
+ \def\TeXdef{TeX}\ifx\TeXdef\lilypondpaperinputencoding
+ \usepackage[latin1]{inputenc}
+ \else
+ \usepackage[\lilypondpaperinputencoding]{inputenc}
+ \fi
+ \pagestyle{empty}
+
+ \usepackage{color}
+
+ \lilypondifundefined{lilypondclassic}
+ {%% If not in `classic' mode, undo LaTeX's page layout settings
+ %% since LilyPond does the layout by itself.
+ \topmargin-1in
+ \headheight0pt\headsep0pt
+ \oddsidemargin-1in
+ \evensidemargin\oddsidemargin}
+
+ {%% Otherwise center output horizontally, without changing the
+ %% vertical positioning.