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>
21 %% \ifx\lilypondstart \undefined
22 %% \input lilyponddefs
25 %% <font setup and note output>
31 %% Handy macros from the LaTeX manual.
32 \long\gdef\lilypondfirst#1#2{#1}
33 \long\gdef\lilypondsecond#1#2{#2}
34 \gdef\lilypondifundefined#1{
35 \expandafter\ifx\csname#1\endcsname\relax
36 \expandafter\lilypondfirst
38 \expandafter\lilypondsecond
45 %% \@nodocument is defined as \relax after `\begin{document}'
46 \lilypondifundefined{@nodocument}
48 %% 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}
60 \lilypondifundefined{lilypondclassic}
62 %% Nullify [La]TeX page layout settings, page layout by LilyPond.
64 \headheight0pt\headsep0pt
66 \evensidemargin\oddsidemargin
69 %% Center staves horizontally on page
70 \ifdim\lilypondpaperlinewidth\lilypondpaperunit > 0pt
71 \hsize\lilypondpaperlinewidth\lilypondpaperunit
72 \lytempdim \paperwidth
73 \advance\lytempdim -\the\hsize
74 \lytempdim 0.5\lytempdim
75 \advance\lytempdim -1in
76 \oddsidemargin \lytempdim
77 \evensidemargin \lytempdim
81 %% TEXINFO workaround: \begin is defined as \outer, use \csname.
82 \csname begin\endcsname{document}}}
86 \lilypondifundefined{lilypondbook}
87 {\lilypondifundefined{lilypondpaperlastpagefill}
88 {\vskip 0pt plus\lilypondpaperinterscorelinefill00 fill}
92 \lilypondifundefined{lilyponddocument}
94 {\def\x{\endgroup\csname end\endcsname{document}}}
97 %% Inversed \loop ... \repeat macro
98 \def\lilypondloop#1\lilypondrepeat{
103 \def\lilyponditerate{
106 \let\lilypondnext \relax
108 \let\lilypondnext \lilyponditerate
113 %% Allow overriding of pagebreak
114 \lilypondifundefined{lilypondpagebreak}
116 \lilypondifundefined{@nodocument}
117 {\gdef\lilypondpagebreak{\eject}}
118 {\gdef\lilypondpagebreak{\newpage}}
122 %% Include \special only once.
123 \gdef\lilypondspecial{
124 \special{header=music-drawing-routines.ps}
125 \gdef\lilypondspecial{}
128 %% The feta characters.
131 \global\font\fetasixteen = feta16
132 \gdef\fetafont{\fetasixteen}
133 \gdef\fetachar#1{\hbox{\fetasixteen#1}}
135 \gdef\topalign#1{\vbox to 0pt{\hbox{#1}\vss}}
136 \gdef\leftalign#1{\hbox to 0pt{#1\hss}}
139 \topalign{\raise#2\outputscale\leftalign{\kern#1\outputscale#3}}}
141 \gdef\lybox#1#2#3#4#5{
142 \lytempdim\baselineskip
143 \advance\lytempdim-#4\outputscale
145 \vbox to#4\outputscale{
146 \leftalign{\kern#1\outputscale\lower#2\outputscale\topalign{#5}}
149 \gdef\lyvrule#1#2#3#4{
151 \vrule width #2\outputscale depth #3\outputscale height #4\outputscale}
153 %% FIXME: 'interscoreline' and 'lilypondPAPERinterscoreline
154 \lilypondifundefined{lilypondpaperinterscorelinefill}
155 {\gdef\lilypondpaperinterscorelinefill{0}}
156 {\gdef\lilypondpaperinterscorelinefill{1}}
158 %% Allow overriding of interscoreline, e.g. for lilypond.py's --preview
159 \lilypondifundefined{interscoreline}
161 \lilypondifundefined{lilypondclassic}
162 {\gdef\interscoreline{}}
163 {\gdef\interscoreline{
164 \vskip\lilypondpaperinterscoreline\lilypondpaperunit
165 plus \lilypondpaperinterscorelinefill fill}}
169 %% Include postscript definitions unless using PDFTeX,
170 %% in that case use pdf definitions.
171 %% MiKTeX workaround: use \csname.
172 \lilypondifundefined{lilypondpostscript}
173 {\lilypondifundefined{pdfoutput}
174 {\input lily-ps-defs }
176 \input lily-pdf-defs }}
179 %% Restore newline functionality (disabled to avoid \par).
180 \endlinechar \lilyponddefsELC
183 %% end lilyponddefs.tex