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
43 %% Urgh. Lilypond uses EC fonts, but texinfo is based on CM. We thus
44 %% have to handle T1 font encoding by ourselves. Note that the following
45 %% code only provides the texinfo interface, not complete access to all
50 \gdef\lilypondECencoding{
82 % \def\tieaccent##1{} % unsupported: this is TS1
91 \sh@ft{29}\vbox to.2ex{
106 \chardef\exclamdown=189
107 \chardef\questiondown=190
130 \catcode `\@=11\relax
131 %% \@nodocument is defined as \relax after `\begin{document}'
132 \lilypondifundefined{@nodocument}
133 {%% either plain TeX or texinfo or not at the beginning of LaTeX input
136 \def\lilypondfontencoding####1{
137 \lilypondECencoding}}}
139 %% provide a proper LaTeX preamble (for A4 paper format)
142 \def\lilyponddocument{}
143 \def\lilypondfontencoding####1{
146 \documentclass[a4paper]{article}
149 \usepackage[\lilypondpaperinputencoding]{inputenc}
151 \lilypondifundefined{lilypondclassic}
152 {%% Nullify [La]TeX page layout settings, page layout by LilyPond.
154 \headheight0pt\headsep0pt
156 \evensidemargin\oddsidemargin}
157 {%% Center staves horizontally on page
158 \ifdim\lilypondpaperlinewidth\lilypondpaperunit > 0pt
159 \hsize\lilypondpaperlinewidth\lilypondpaperunit
160 \lytempdim \paperwidth
161 \advance\lytempdim -\the\hsize
162 \lytempdim 0.5\lytempdim
163 \advance\lytempdim -1in
164 \oddsidemargin \lytempdim
165 \evensidemargin \lytempdim
168 %% TEXINFO workaround: \begin is defined as \outer, use \csname.
169 \csname begin\endcsname{document}}}
173 \lilypondifundefined{lilypondbook}
174 {\lilypondifundefined{lilypondpaperlastpagefill}
175 {\vskip 0pt plus\lilypondpaperinterscorelinefill00 fill}
179 \lilypondifundefined{lilyponddocument}
181 {\def\x{\endgroup\csname end\endcsname{document}}}
184 %% Allow overriding of pagebreak
185 \lilypondifundefined{lilypondpagebreak}
186 {\lilypondifundefined{@nodocument}
187 {\gdef\lilypondpagebreak{\eject}}
188 {\gdef\lilypondpagebreak{\newpage}}}
191 %% Allow overriding of pagebreak
192 \lilypondifundefined{lilypondnopagebreak}
193 {\lilypondifundefined{@nodocument}
194 {\gdef\lilypondnopagebreak{}}
195 {\gdef\lilypondnopagebreak{\nopagebreak}}}
197 %% Include \special only once.
198 \gdef\lilypondspecial{
199 \special{header=music-drawing-routines.ps}
200 \gdef\lilypondspecial{}}
202 %% The feta characters.
205 \global\font\fetasixteen = feta16
206 \gdef\fetafont{\fetasixteen}
207 \gdef\fetachar#1{\hbox{\fetasixteen#1}}
209 \gdef\topalign#1{\vbox to 0pt{\hbox{#1}\vss}}
210 \gdef\leftalign#1{\hbox to 0pt{#1\hss}}
213 \topalign{\raise#2\outputscale\leftalign{\kern#1\outputscale#3}}}
215 \gdef\lybox#1#2#3#4#5{
216 \lytempdim\baselineskip
217 \advance\lytempdim-#4\outputscale
219 \vbox to#4\outputscale{
220 \leftalign{\kern#1\outputscale\lower#2\outputscale\topalign{#5}}
223 \gdef\lyvrule#1#2#3#4{
225 \vrule width #2\outputscale depth #3\outputscale height #4\outputscale}
227 %% FIXME: 'interscoreline' and 'lilypondPAPERinterscoreline
228 \lilypondifundefined{lilypondpaperinterscorelinefill}
229 {\gdef\lilypondpaperinterscorelinefill{0}}
230 {\gdef\lilypondpaperinterscorelinefill{1}}
232 %% Allow overriding of interscoreline, e.g. for lilypond.py's --preview
233 \lilypondifundefined{interscoreline}
234 {\lilypondifundefined{lilypondclassic}
235 {\gdef\interscoreline{}}
236 {\gdef\interscoreline{
237 \vskip\lilypondpaperinterscoreline\lilypondpaperunit
238 plus \lilypondpaperinterscorelinefill fill}}}
241 %% Include postscript definitions unless using PDFTeX,
242 %% in that case use pdf definitions.
243 %% MiKTeX workaround: use \csname.
244 \lilypondifundefined{lilypondpostscript}
245 {\lilypondifundefined{pdfoutput}
246 {\input lily-ps-defs }
248 \input lily-pdf-defs }}
251 %% Restore newline functionality (disabled to avoid \par).
252 \endlinechar \lilyponddefsELC
255 %% end lilyponddefs.tex