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 \def\lilypondfontencoding##1{}}}
54 %% provide a proper LaTeX preamble (for A4 paper format)
57 \def\lilyponddocument{}
58 \def\lilypondfontencoding##1{
59 \fontencoding{##1}\selectfont}
60 \documentclass[a4paper]{article}
63 \usepackage[\lilypondpaperinputencoding]{inputenc}
65 \lilypondifundefined{lilypondclassic}
66 {%% Nullify [La]TeX page layout settings, page layout by LilyPond.
68 \headheight0pt\headsep0pt
70 \evensidemargin\oddsidemargin}
71 {%% Center staves horizontally on page
72 \ifdim\lilypondpaperlinewidth\lilypondpaperunit > 0pt
73 \hsize\lilypondpaperlinewidth\lilypondpaperunit
74 \lytempdim \paperwidth
75 \advance\lytempdim -\the\hsize
76 \lytempdim 0.5\lytempdim
77 \advance\lytempdim -1in
78 \oddsidemargin \lytempdim
79 \evensidemargin \lytempdim
82 %% TEXINFO workaround: \begin is defined as \outer, use \csname.
83 \csname begin\endcsname{document}}}
87 \lilypondifundefined{lilypondbook}
88 {\lilypondifundefined{lilypondpaperlastpagefill}
89 {\vskip 0pt plus\lilypondpaperinterscorelinefill00 fill}
93 \lilypondifundefined{lilyponddocument}
95 {\def\x{\endgroup\csname end\endcsname{document}}}
98 %% Inversed \loop ... \repeat macro
99 \def\lilypondloop#1\lilypondrepeat{
100 \def\lilypondbody{#1}
103 \def\lilyponditerate{
106 \let\lilypondnext \relax
108 \let\lilypondnext \lilyponditerate
112 %% Allow overriding of pagebreak
113 \lilypondifundefined{lilypondpagebreak}
114 {\lilypondifundefined{@nodocument}
115 {\gdef\lilypondpagebreak{\eject}}
116 {\gdef\lilypondpagebreak{\newpage}}}
119 %% Include \special only once.
120 \gdef\lilypondspecial{
121 \special{header=music-drawing-routines.ps}
122 \gdef\lilypondspecial{}}
124 %% The feta characters.
127 \global\font\fetasixteen = feta16
128 \gdef\fetafont{\fetasixteen}
129 \gdef\fetachar#1{\hbox{\fetasixteen#1}}
131 \gdef\topalign#1{\vbox to 0pt{\hbox{#1}\vss}}
132 \gdef\leftalign#1{\hbox to 0pt{#1\hss}}
135 \topalign{\raise#2\outputscale\leftalign{\kern#1\outputscale#3}}}
137 \gdef\lybox#1#2#3#4#5{
138 \lytempdim\baselineskip
139 \advance\lytempdim-#4\outputscale
141 \vbox to#4\outputscale{
142 \leftalign{\kern#1\outputscale\lower#2\outputscale\topalign{#5}}
145 \gdef\lyvrule#1#2#3#4{
147 \vrule width #2\outputscale depth #3\outputscale height #4\outputscale}
149 %% FIXME: 'interscoreline' and 'lilypondPAPERinterscoreline
150 \lilypondifundefined{lilypondpaperinterscorelinefill}
151 {\gdef\lilypondpaperinterscorelinefill{0}}
152 {\gdef\lilypondpaperinterscorelinefill{1}}
154 %% Allow overriding of interscoreline, e.g. for lilypond.py's --preview
155 \lilypondifundefined{interscoreline}
156 {\lilypondifundefined{lilypondclassic}
157 {\gdef\interscoreline{}}
158 {\gdef\interscoreline{
159 \vskip\lilypondpaperinterscoreline\lilypondpaperunit
160 plus \lilypondpaperinterscorelinefill fill}}}
163 %% Include postscript definitions unless using PDFTeX,
164 %% in that case use pdf definitions.
165 %% MiKTeX workaround: use \csname.
166 \lilypondifundefined{lilypondpostscript}
167 {\lilypondifundefined{pdfoutput}
168 {\input lily-ps-defs }
170 \input lily-pdf-defs }}
173 %% Restore newline functionality (disabled to avoid \par).
174 \endlinechar \lilyponddefsELC
177 %% end lilyponddefs.tex