1 %%% lilyponddefs.tex -- TeX macros for LilyPond output.
3 %%% source file of the GNU LilyPond music typesetter
5 %%% (c) 1998--2004 Jan Nieuwenhuizen <janneke@gnu.org>
6 %%% Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 %%% Mats Bengtsson <mats.bengtsson@s3.kth.se>
9 %% Avoid \par while reading this file.
10 \edef\lilyponddefsELC{\the\endlinechar}%
13 %% This runs with plain TeX, LaTeX, pdftex, and texinfo.
15 %% To avoid interferences, lilyponddefs.tex must be loaded within a group.
16 %% It is loaded only once, so the definitions must be global.
18 %% The overall structure of a file created by LilyPond is as follows:
20 %% <lilypond parameter definitions>
22 %% \ifx\lilypondstart \undefined
23 %% \input lilyponddefs
32 %% Handy macros from the LaTeX manual.
33 \long\gdef\lilypondfirst#1#2{#1}
34 \long\gdef\lilypondsecond#1#2{#2}
35 \gdef\lilypondifundefined#1{
36 \expandafter\ifx\csname#1\endcsname\relax
37 \expandafter\lilypondfirst
39 \expandafter\lilypondsecond
47 %% \@nodocument is defined as \relax after `\begin{document}'
48 \lilypondifundefined{@nodocument}
49 {%% either plain TeX or texinfo or not at the beginning of LaTeX input
52 %% provide a proper LaTeX preamble (for A4 paper format)
55 \def\lilyponddocument{}
56 \documentclass[a4paper]{article}
61 \lilypondifundefined{lilypondclassic}
62 {%% Nullify [La]TeX page layout settings, page layout by LilyPond.
64 \headheight0pt\headsep0pt
66 \evensidemargin\oddsidemargin}
67 {%% Center staves horizontally on page
68 \ifdim\lilypondpaperlinewidth\lilypondpaperunit > 0pt
69 \hsize\lilypondpaperlinewidth\lilypondpaperunit
70 \lytempdim \paperwidth
71 \advance\lytempdim -\the\hsize
72 \lytempdim 0.5\lytempdim
73 \advance\lytempdim -1in
74 \oddsidemargin \lytempdim
75 \evensidemargin \lytempdim
78 %% TEXINFO workaround: \begin is defined as \outer, use \csname.
79 \csname begin\endcsname{document}}}
83 \lilypondifundefined{lilypondbook}
84 {\lilypondifundefined{lilypondpaperlastpagefill}
85 {\vskip 0pt plus\lilypondpaperinterscorelinefill00 fill}
89 \lilypondifundefined{lilyponddocument}
91 {\def\x{\endgroup\csname end\endcsname{document}}}
94 %% Inversed \loop ... \repeat macro
95 \def\lilypondloop#1\lilypondrepeat{
102 \let\lilypondnext \relax
104 \let\lilypondnext \lilyponditerate
108 %% Allow overriding of pagebreak
109 \lilypondifundefined{lilypondpagebreak}
110 {\lilypondifundefined{@nodocument}
111 {\gdef\lilypondpagebreak{\eject}}
112 {\gdef\lilypondpagebreak{\newpage}}}
115 %% Include \special only once.
116 \gdef\lilypondspecial{
117 \special{header=music-drawing-routines.ps}
118 \gdef\lilypondspecial{}}
120 %% The feta characters.
123 \global\font\fetasixteen = feta16
124 \gdef\fetafont{\fetasixteen}
125 \gdef\fetachar#1{\hbox{\fetasixteen#1}}
127 \gdef\topalign#1{\vbox to 0pt{\hbox{#1}\vss}}
128 \gdef\leftalign#1{\hbox to 0pt{#1\hss}}
131 \topalign{\raise#2\outputscale\leftalign{\kern#1\outputscale#3}}}
133 \gdef\lybox#1#2#3#4#5{
134 \lytempdim\baselineskip
135 \advance\lytempdim-#4\outputscale
137 \vbox to#4\outputscale{
138 \leftalign{\kern#1\outputscale\lower#2\outputscale\topalign{#5}}
141 \gdef\lyvrule#1#2#3#4{
143 \vrule width #2\outputscale depth #3\outputscale height #4\outputscale}
145 %% FIXME: 'interscoreline' and 'lilypondPAPERinterscoreline
146 \lilypondifundefined{lilypondpaperinterscorelinefill}
147 {\gdef\lilypondpaperinterscorelinefill{0}}
148 {\gdef\lilypondpaperinterscorelinefill{1}}
150 %% Allow overriding of interscoreline, e.g. for lilypond.py's --preview
151 \lilypondifundefined{interscoreline}
152 {\lilypondifundefined{lilypondclassic}
153 {\gdef\interscoreline{}}
154 {\gdef\interscoreline{
155 \vskip\lilypondpaperinterscoreline\lilypondpaperunit
156 plus \lilypondpaperinterscorelinefill fill}}}
159 %% Include postscript definitions unless using PDFTeX,
160 %% in that case use pdf definitions.
161 %% MiKTeX workaround: use \csname.
162 \lilypondifundefined{lilypondpostscript}
163 {\lilypondifundefined{pdfoutput}
164 {\input lily-ps-defs }
166 \input lily-pdf-defs }}
169 %% Restore newline functionality (disabled to avoid \par).
170 \endlinechar \lilyponddefsELC
173 %% end lilyponddefs.tex