]> git.donarmstrong.com Git - lilypond.git/blob - tex/lilyponddefs.tex
3f73f0d07973aceb4fce1f0945a728ae3fd83718
[lilypond.git] / tex / lilyponddefs.tex
1 %%
2 %% include file for LilyPond
3 %%
4 %% this file defines various macros to accomodate lilypond output
5 %% 
6 %% let's not make par before endinput
7 %
8 % TeXbook ex 7.7
9 \def\ifundefined#1{\expandafter\ifx\csname#1\endcsname\relax}
10 %
11 % skip if included already
12 \def\SkipLilydefs{\endinput}
13 \ifundefined{EndLilyPondOutput}
14         \def\EndLilyPondOutput{\csname bye\endcsname}
15         \def\SkipLilydefs{}
16 \fi
17 \SkipLilydefs
18 %
19 \ifundefined{mudelacopyright}
20         \def\mudelacopyright{\copyright\ \number\year}
21 \fi
22 \ifundefined{LilyIdString}
23         \def\LilyIdString{Lily was here}
24 \fi
25
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27 % macros to shorten other definitions
28 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
29 \def\musicmathdef#1#2{\def#1{\musicmathchar{#2}}}
30 \def\musicmathchar#1{\musicmathfont\char#1}
31
32 \def\topalign#1{\vbox to 0pt{#1\vss}}
33 \def\botalign#1{\vbox to 0pt{\vss #1}}
34
35 \def\centeralign#1{\hbox to 0pt{\hss#1\hss}}
36 \def\leftalign#1{\hbox to 0pt{#1\hss}}
37 \def\rightalign#1{\hbox to 0pt{\hss#1}}
38
39
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41 %% set up dimensions
42 \parindent=0pt
43 \newdimen\smallspace
44 \newdimen\interlinedist
45
46 \newdimen\stemthickness
47 \newcount\n                     %duh. meaningful identifiers.
48 \newdimen\staffheight
49 \newdimen\notewidth
50 \newdimen\noteheight
51 \newdimen\staffrulethickness
52 \newdimen\interstaffrule
53 \newdimen\dist
54
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 % set fonts and primary dimensions
57 % ugh
58 \def\musixtwentydefs{
59         \twentyfonts
60         \musixcalc
61 }
62
63   \def\cmrtwenty{
64           \font\smalltextfont=cmr8
65         \font\meterfont=cmbx12 at 15pt
66           \font\textmusic=cmmi12
67 %        \font\musicmathfont=cmsy10 %%Not used?? /MB
68         \ifundefined{documentclass}
69                 \font\normaltextfont=cmr10 %\textfont is a primitive
70                 \font\italicfont=cmti10 scaled \magstep1
71                 \font\boldfont=cmbx10
72                 \font\largefont=cmbx12
73                 \font\typewriterfont=cmtt10
74                 %\font\Largefont=cmbx14
75                 \font\Largefont=cmbx12 scaled \magstep 2
76                 \font\hugefont=cmbx12 scaled \magstep 3
77         \else
78 %                \def\settext##1{{\normalfont\normalsize ##1}}
79                 \def\settext##1{{\normalfont ##1}}
80                 \def\setitalic##1{\textit{\normalsize ##1}}
81                 \def\setbold##1{\textbf{\normalsize ##1}}
82                 \def\settypewriter##1{\texttt{\normalsize ##1}}
83                 \def\setlarge##1{\textbf{\large ##1}}
84                 \def\setLarge##1{\textbf{\Large ##1}}
85                 \def\sethuge##1{\textbf{\huge ##1}}
86         \fi
87   }
88   \def\cmrsixteen{
89           \font\smalltextfont=cmr6
90           \font\meterfont=cmbx12
91           \font\textmusic=cmmi10
92         \ifundefined{documentclass}
93                 \font\normaltextfont=cmr8 %\textfont is a primitive
94                 \font\italicfont=cmti9
95                 \font\boldfont=cmbx8
96                 \font\typewriterfont=cmtt9
97                 \font\largefont=cmbx10
98                 \font\Largefont=cmbx12
99                 \font\hugefont=cmbx12 scaled \magstep 2
100         \else
101                 \def\settext##1{{\normalfont\footnotesize ##1}}
102                 \def\setitalic##1{\textit{\small ##1}}
103                 \def\setbold##1{\textbf{\footnotesize ##1}}
104                 \def\settypewriter##1{\texttt{\normalsize ##1}}
105                 \def\setlarge##1{\textbf{\normalsize ##1}}
106                 \def\setLarge##1{\textbf{\large ##1}}
107                 \def\sethuge##1{\textbf{\Large ##1}}
108         \fi
109   }
110   \def\cmrthirteen{
111           \font\smalltextfont=cmr6
112           \font\meterfont=cmbx9
113           \font\textmusic=cmmi9
114         \ifundefined{documentclass}
115                 \font\normaltextfont=cmr7
116                 \font\italicfont=cmti7
117                 \font\boldfont=cmbx7
118                 \font\largefont=cmbx9
119                 \font\typewriterfont=cmtt7
120                 \font\Largefont=cmbx10
121                 \font\hugefont=cmbx12
122         \else
123                 \def\settext##1{{\normalfont\scriptsize ##1}}
124                 \def\setitalic##1{\textit{\scriptsize ##1}}
125                 \def\setbold##1{\textbf{\scriptsize ##1}}
126                 \def\setlarge##1{\textbf{\small ##1}}
127                 \def\setLarge##1{\textbf{\normalsize ##1}}
128                 \def\sethuge##1{\textbf{\large ##1}}
129         \fi
130   }
131   \def\cmreleven{
132           \font\smalltextfont=cmr5
133           \font\meterfont=cmbx8
134           \font\textmusic=cmmi8
135         \ifundefined{documentclass}
136                 \font\normaltextfont=cmr6
137                 \font\italicfont=cmti6
138                 \font\boldfont=cmbx6
139                 \font\typewriterfont=cmtt6
140                 \font\largefont=cmbx8
141                 \font\Largefont=cmbx9
142                 \font\hugefont=cmbx10
143         \else
144                 \def\settext##1{{\normalfont\tiny ##1}}
145                 \def\setitalic##1{\textit{\tiny ##1}}
146                 \def\setbold##1{\textbf{\tiny ##1}}
147                 \def\setlarge##1{\textbf{\footnotesize ##1}}
148                 \def\setLarge##1{\textbf{\small ##1}}
149                 \def\sethuge##1{\textbf{\normalsize ##1}}
150         \fi
151   }
152 \def\musixsixteendefs{
153         \sixteenfonts
154         \musixcalc
155 }
156 \def\musixtwentysixdefs{
157         \twentysixfonts
158         \musixcalc
159 }
160 \def\musixthirteendefs{
161         \thirteenfonts
162         \musixcalc
163 }
164 \def\musixelevendefs{
165         \elevenfonts
166         \musixcalc
167 }
168
169 \def\textsharp{\raise.4ex\hbox{\textmusic\char"5D}}
170 \def\textnatural{\raise.4ex\hbox{\textmusic\char"5C}}
171 \def\textflat{\raise.2ex\hbox{\textmusic\char"5B}}
172
173
174
175
176 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
177 % do derivative calcs
178
179 % this has to be synced with the font definition
180 \def\musixcalc{
181         \staffheight=\mudelapaperbarsize pt
182         \interlinedist=\staffheight
183         \divide\interlinedist by 4
184         \notewidth=\mudelapapernotewidth pt
185
186         \smallspace=.3\interlinedist
187         \interstaffrule=\staffheight
188         \divide\interstaffrule by 4
189         \staffrulethickness=\mudelapaperrulethickness pt
190         \stemthickness=\staffrulethickness
191 }
192
193 % stacked numbers; may be overruled in fetdefs
194 \def\generalmeter#1#2{\vbox to 0pt{\vss\hbox{\meterfont
195          #1}\nointerlineskip
196          \hbox{\meterfont #2}\vss}}
197
198 % stacked horizontal lines 
199
200 \def\interscoreline{\vskip 16pt}
201 \def\setdynamic#1{\dynfont #1}
202 \def\setfinger#1{\fingerfont #1}
203 \def\setnumber#1{\fetanummer #1}
204 \def\setmark#1{\markfont #1}
205
206 % big fat marks, if errors are detected.
207 \def\columnerrormark{\placebox{-5pt}{0pt}{\bf C!}}
208 \def\scorelineerrormark{\placebox{0pt}{-10pt}{\bf L!}}
209 \def\errormark{{\bf E!}}
210 \def\unknown{{\bf u}}
211
212 \input dyndefs
213 \input fetdefs
214
215
216
217 \def\emptybar{}
218
219 \def\defaultthinbar{\thinbar{\staffheight}}
220 \def\defaultthickbar{\thickbar{\staffheight}}
221 %? what-s wrong with rightalign?
222 \def\repeatstopbar{\rightalign{\repeatcolon\kern2\smallspace\defaultthinbar\kern\smallspace\defaultthickbar}}
223 \def\repeatstartbar{\hbox{\defaultthickbar\kern\smallspace\defaultthinbar\kern2\smallspace\repeatcolon}}
224 \def\repeatstopstart{\hbox{\repeatcolon\kern2\smallspace\defaultthickbar\kern\smallspace\defaultthickbar\kern2\smallspace\repeatcolon}}
225
226 %compatibility
227 %urg
228 \fetdef\repeatcolon{18}
229 \def\repeatbar{\repeatstopbar}
230 \def\startrepeat{\repeatstartbar}
231 \def\repeatbarstartrepeat{\repeatstopstart}
232
233 \def\vruler#1{{%
234         \def\wid{\dimen0}%
235         \def\inc{\dimen1}%
236         \wid=#1pt
237         \inc=\wid
238         \divide\inc by #1
239         \divide\wid by 2
240         \here=-\wid
241         \loop\ifdim\here<\wid\advance\here by\inc
242                 \hbox to0pt{\vbox to0pt{\vss\hrule width2pt height 0.05pt\kern\here}\hss}%
243         \repeat%
244 }}
245 \def\hruler#1#2{\hbox{%
246         \def\wid{\dimen0}%
247         \def\here{\dimen3}%
248         \wid=#1pt
249         \divide\wid by 2
250         \here=-\wid
251         \loop\ifdim\here<\wid\advance\here by #2
252                 \hbox to0pt{\kern\here\vrule width0.05pt height 1pt depth 1pt\hss}%
253         \repeat%
254 }}
255
256
257 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
258 % parametric symbols
259 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
260
261 \def\doublebar#1{\hbox{\thinbar{#1}\hskip\smallspace\thinbar{#1}}}
262 \def\thinbar#1{\dimen0=#1%
263         \vrule height .5\dimen0 depth .5\dimen0 width 1.6\staffrulethickness} % TODO parametric.
264 \def\thickbar#1{\dimen0=#1%
265         \vrule height .5\dimen0 depth .5\dimen0 width 2\smallspace}
266 \def\maatstreep#1{\thinbar{#1}}
267 \def\startbar#1{\leftalign{\thickbar{#1}\kern\smallspace\thinbar{#1}}}
268 \def\finishbar#1{\rightalign{\thinbar{#1}\kern\smallspace\thickbar{#1}}}
269 \def\fatdoublebar#1{\hbox{\phantom{\repeatcolon\kern2\smallspace}\thickbar{#1}\kern\smallspace\thickbar{#1}}}
270
271
272
273 % ugh
274 % see e.g. input/test/beam-pos.ly
275 %
276 % something's wrong with the aligment; sometimes all symbols
277 % look to be placed a bit too high (there's an ugly fix for
278 % the staccato-dot in script.cc)
279 % but this varies from line to line: it seems that xdvi
280 % does some rounding; i can't really check this from screen on i
281 % 600x600 res.
282 %
283 \def\rulesym#1#2{\dimen0=#1%
284         \vrule height .5\dimen0 depth .5\dimen0 width #2}
285 \def\shiftedrulesym#1#2{\dimen0=#1%
286         \vrule height .7\dimen0 depth .3\dimen0 width #2}
287 \def\tinyrulesym#1#2{\dimen0=#1%
288         \vrule height .1\dimen0 depth .1\dimen0 width #2}
289 %would be nice for checking alignment
290 \def\openrulesym#1#2{\dimen0=#1%
291         \vbox to \dimen0{\vss%
292         \hbox{\vrule height .1\dimen0 width #2}%
293         \hbox{\vrule height .2\dimen0 width 0pt}%
294         \hbox{\vrule height .4\dimen0 width #2}%
295         \hbox{\vrule height .2\dimen0 width 0pt}%
296         \hbox{\vrule height .1\dimen0 width #2}%
297         \vss}}
298 %\let\rulesym\shiftedrulesym
299 %\let\rulesym\tinyrulesym
300 %\let\rulesym\openrulesym
301
302 \ifundefined{documentclass}
303         \def\settext#1{\normaltextfont #1}
304         \def\setitalic#1{\italicfont #1}
305         \def\setbold#1{\boldfont #1}
306         \def\settypewriter#1{\typewriterfont #1}
307         \def\setlarge#1{\largefont #1}
308         \def\setLarge#1{\Largefont #1}
309         \def\sethuge#1{\hugefont #1}
310 \fi
311 % the interline symbol. Redefine to remove it.
312 \def\defaultlineseparator{\vbox{\mussepline\vskip -5pt\mussepline}}
313 \def\lineseparator{\defaultlineseparator}
314 \def\beauty{%
315         \par\vskip 10pt plus 30pt minus 10pt\par
316         \hskip -5pt\lineseparator
317         \par\vskip 10pt plus 30pt minus 10pt\par
318 }
319
320
321 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
322 \def\postheader{}
323
324
325
326
327 \ifundefined{documentclass}%
328 %        \ifundefined{nolilyfooter}
329 % Can't nest \ifundefined ??
330         \footline={\ifnum\pageno=1\smalltextfont\mudelacopyright\hfil \LilyIdString
331                 \else\hfil\the\pageno\hfil\fi}%
332         \advance\hoffset by -.6in
333  %       \fi%
334 \else
335 \let\nopagenumbers\relax
336         %% FIXME
337         \def\ps@plain{
338                 \renewcommand{\@oddhead}{}%
339                 \renewcommand{\@evenfoot}{}%
340                 \renewcommand{\@evenhead}{}%
341                 \renewcommand{\@oddfoot}{%
342                         \ifnum\thepage=1{\hfil \LilyIdString}%
343                         \else{%
344                                 foo\hfil\the\pageno\hfil}%
345                         \fi}}
346         \def\ps@empty{
347                 \renewcommand{\@oddhead}{}%
348                 \renewcommand{\@evenfoot}{}%
349                 \renewcommand{\@evenhead}{}%
350                 \renewcommand{\@oddfoot}{%
351                         \ifnum\thepage=1{\hfil \LilyIdString}%
352                         \else{foo\hfil\the\pageno\hfil}%
353                         \fi}}%
354 \fi
355 \nopagenumbers
356
357 % debugging stuff:
358 % \vbox to 0pt{\vskip .5cm \hruler{48}{3pt}\vss}