- {
- %% either plain TeX or texinfo or not at the beginning of LaTeX input
- \def\x{\endgroup}}
- {
- %% FIXME: a4
- %% provide a proper LaTeX preamble (for A4 paper format)
- \def\x{
- \endgroup
- \def\lilyponddocument{}
- \documentclass[a4paper]{article}
- %% safe-mode
- \nofiles
- %% Nullify [La]TeX page layout settings, page layout by LilyPond.
- \pagestyle{empty}
- \topmargin-1in
- %% FIXME: empirical computer science: page is ca 5mm too low.
- \advance\topmargin-5mm
- \headheight0pt\headsep0pt
- \oddsidemargin-1in
- \evensidemargin\oddsidemargin
- \parindent 0pt
- %% TEXINFO workaround: \begin is defined as \outer, use \csname.
- \csname begin\endcsname{document}}}
+ {%% 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.
+ \hsize\lilypondpaperlinewidth\lilypondpaperunit
+ \lytempdim \paperwidth
+ \advance\lytempdim -\the\hsize
+ \lytempdim 0.5\lytempdim
+ \advance\lytempdim -1in
+ \oddsidemargin \lytempdim
+ \evensidemargin \lytempdim}
+
+ \parindent 0pt
+
+ %% We can't directly say `\begin{document}' in this macro since
+ %% older versions of texinfo.tex define \begin as \outer; this
+ %% means that it causes an error if \begin is found within another
+ %% macro (even if the corresponding code will never be executed).
+ %% As a workaround we use \csname to call \begin.
+ \csname begin\endcsname{document}}}