]> git.donarmstrong.com Git - lilypond.git/blob - tex/lilyponddefs.tex
8a03396e189ab912022e661a179eeeefa159fc40
[lilypond.git] / tex / lilyponddefs.tex
1 %%
2 %% include file for LilyPond
3 %%
4 %% this file defines various macros to accomodate lilypond output
5
6 % TeXbook ex 7.7
7 \def\ifundefined#1{\expandafter\ifx\csname#1\endcsname\relax}
8
9 % skip if included already
10 \def\SkipLilydefs{\endinput}
11 \ifundefined{EndLilyPondOutput}
12         \def\EndLilyPondOutput{\csname bye\endcsname}
13         \def\SkipLilydefs{}
14 \fi
15 \SkipLilydefs
16
17 \ifundefined{mudelacopyright}
18         \def\mudelacopyright{\copyright\ \number\year}
19 \fi
20 \ifundefined{LilyIdString}
21         \def\LilyIdString{Lily was here}
22 \fi
23
24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25 % macros to shorten other definitions
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27 \def\musicdef#1#2{\def#1{\musicchar{#2}}}
28 \def\musicchar#1{\musicfnt\char#1}
29 \def\rationalmultiply#1*#2/#3{\multiply #1 by #2 \divide #1 by #3}
30
31
32 \def\maccentraise#1#2{\dimen0=\noteheight
33         \rationalmultiply\dimen0*#2%
34         \raise\dimen0\hbox{#1}}
35 \def\maccentdef#1#2#3{\def#1{\maccentraise{\musicchar{#2}}{#3}}}
36 \def\vertcenter#1{\vbox to 0pt{\vss #1\vss}}
37
38 \def\musicmathdef#1#2{\def#1{\musicmathchar{#2}}}
39 \def\musicmathchar#1{\musicmathfont\char#1}
40
41 \def\topalign#1{\vbox to 0pt{#1\vss}}
42 \def\botalign#1{\vbox to 0pt{\vss #1}}
43
44 \def\centeralign#1{\hbox to 0pt{\hss#1\hss}}
45 \def\leftalign#1{\hbox to 0pt{#1\hss}}
46 \def\rightalign#1{\hbox to 0pt{\hss#1}}
47
48
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 %% set up dimensions
51 \parindent=0pt
52 \newdimen\smallspace
53 \newdimen\interlinedist
54 \newdimen\stemthickness
55 \newcount\n
56 \newdimen\staffheight
57 \newdimen\notewidth
58 \newdimen\noteheight
59 \newdimen\staffrulethickness
60 \newdimen\interstaffrule
61 \newdimen\dist
62
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 % set fonts and primary dimensions
65 % ugh
66 \def\musixtwentydefs{
67         \twentyfonts
68         \musixcalc
69 }
70
71 \def\cmrtwenty{
72         \font\meterfont=cmbx15
73         \font\italicfont=cmti10
74         \font\musicmathfont=cmsy10
75         \font\normaltextfont=cmr10 %\textfont is a primitive
76         \font\smalltextfont=cmr8
77         \font\boldfont=cmbx10
78         \font\textmusic=cmmi12
79 }
80 \def\cmrsixteen{
81         \font\smalltextfont=cmr6
82         \font\normaltextfont=cmr8 %\textfont is a primitive
83         \font\meterfont=cmbx12
84         \font\italicfont=cmti8
85         \font\textmusic=cmmi10
86         \font\boldfont=cmbx8
87 }
88 \def\cmreleven{
89         \font\smalltextfont=cmr5
90         \font\normaltextfont=cmr6
91         \font\meterfont=cmbx8
92         \font\italicfont=cmti6
93         \font\textmusic=cmmi8
94         \font\boldfont=cmbx6
95 }
96
97 \def\cmrthirteen{
98         \font\smalltextfont=cmr6
99         \font\normaltextfont=cmr7
100         \font\meterfont=cmbx9
101         \font\italicfont=cmti7
102         \font\textmusic=cmmi9
103         \font\boldfont=cmbx7
104 }
105 \def\musixsixteendefs{
106         \sixteenfonts
107         \musixcalc
108 }
109 \def\musixtwentysixdefs{
110         \twentysixfonts
111         \musixcalc
112 }
113 \def\musixthirteendefs{
114         \thirteenfonts
115         \musixcalc
116 }
117 \def\musixelevendefs{
118         \elevendefs
119         \musixcalc
120 }
121
122 \def\textsharp{\raise.4ex\hbox{\textmusic\char"5D}}
123 \def\textnatural{\raise.4ex\hbox{\textmusic\char"5C}}
124 \def\textflat{\raise.2ex\hbox{\textmusic\char"5B}}
125
126
127
128
129 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
130 % do derivative calcs
131
132 % this has to be synced with the font definition
133 \def\musixcalc{
134         \staffheight=\mudelapaperbarsize pt
135         \interlinedist=\staffheight
136         \divide\interlinedist by 4
137         \notewidth=\mudelapapernotewidth pt
138
139         \smallspace=.3\interlinedist
140         \interstaffrule=\staffheight
141         \divide\interstaffrule by 4
142         \staffrulethickness=\mudelapaperrulethickness pt
143         \stemthickness=\staffrulethickness
144 }
145
146 % stacked numbers; may be overruled in fetdefs
147 \def\generalmeter#1#2{\vbox to 0pt{\vss\hbox{\meterfont
148          #1}\nointerlineskip
149          \hbox{\meterfont #2}\vss}}
150
151 % stacked horizontal lines 
152
153 \input dyndefs
154 \input fetdefs
155
156 %\input taupindefs
157 %\input eglerdefs
158
159
160 \def\emptybar{}
161
162 \def\defaultthinbar{\thinbar{\staffheight}}
163 \def\defaultthickbar{\thickbar{\staffheight}}
164 %? what-s wrong with rightalign?
165 \def\repeatstopbar{\hss\rightalign{\repeatcolon\hskip2\smallspace\defaultthinbar\hskip\smallspace\defaultthickbar}}
166 \def\repeatstartbar{\hbox{\defaultthickbar\kern\smallspace\defaultthinbar\kern2\smallspace\repeatcolon}}
167 \def\repeatstopstart{\hbox{\repeatcolon\kern2\smallspace\defaultthickbar\kern\smallspace\defaultthickbar\kern2\smallspace\repeatcolon}}
168
169 %compatibility
170 \def\repeatbar{\repeatstopbar}
171 \def\startrepeat{\repeatstartbar}
172 \def\repeatbarstartrepeat{\repeatstopstart}
173
174 \def\vruler#1{{%
175         \def\wid{\dimen0}%
176         \def\inc{\dimen1}%
177         \wid=#1pt
178         \inc=\wid
179         \divide\inc by #1
180         \divide\wid by 2
181         \here=-\wid
182         \loop\ifdim\here<\wid\advance\here by\inc
183                 \hbox to0pt{\vbox to0pt{\vss\hrule width2pt height 0.05pt\kern\here}\hss}%
184         \repeat%
185 }}
186 \def\hruler#1#2{\hbox{%
187         \def\wid{\dimen0}%
188         \def\here{\dimen3}%
189         \wid=#1pt
190         \divide\wid by 2
191         \here=-\wid
192         \loop\ifdim\here<\wid\advance\here by #2
193                 \hbox to0pt{\kern\here\vrule width0.05pt height 1pt depth 1pt\hss}%
194         \repeat%
195 }}
196
197
198 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
199 % parametric symbols
200 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
201
202 \def\doublebar#1{\hbox{\thinbar{#1}\hskip\smallspace\thinbar{#1}}}
203 \def\thinbar#1{\dimen0=#1%
204         \vrule height .5\dimen0 depth .5\dimen0 width 1.6\staffrulethickness} % TODO parametric.
205 \def\thickbar#1{\dimen0=#1%
206         \vrule height .5\dimen0 depth .5\dimen0 width 2\smallspace}
207 \def\maatstreep#1{\thinbar{#1}}
208 \def\startbar#1{\leftalign{\thickbar{#1}\kern\smallspace\thinbar{#1}}}
209 \def\finishbar#1{\rightalign{\thinbar{#1}\kern\smallspace\thickbar{#1}}}
210
211
212 \def\stem#1#2{\hbox{\kern -.5\stemthickness
213         \vrule width\stemthickness height#2 depth-#1}}
214
215 \def\placebox#1#2#3{%
216         \botalign{\hbox{\raise #1\leftalign{\kern #2{}#3}}}%
217 }
218
219
220 \def\rulesym#1#2{\dimen0=#1%
221         \vrule height .5\dimen0 depth .5\dimen0 width #2}
222 \def\settext#1{\normaltextfont #1}
223 \def\setitalic#1{\italicfont #1}
224 \def\setbold#1{\boldfont #1}
225 \def\setdynamic#1{\dynfont #1}
226 \def\setfinger#1{\fingerfont #1}
227
228 % the interline symbol. Redefine to remove it.
229 \def\defaultlineseparator{\vbox{\mussepline\vskip -5pt\mussepline}}
230 \def\lineseparator{\defaultlineseparator}
231 \def\beauty{%
232         \par\vskip 10pt plus 30pt minus 10pt\par
233         \hskip -5pt\lineseparator
234         \par\vskip 10pt plus 30pt minus 10pt\par
235 }
236
237
238 \def\interscoreline{\vskip 16pt}
239         
240 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
241 % big fat marks, if errors are detected.
242 \def\columnerrormark{\placebox{-5pt}{0pt}{\bf C!}}
243 \def\scorelineerrormark{\placebox{0pt}{-10pt}{\bf L!}}
244 \def\errormark{{\bf E!}}
245 \def\unknown{{\bf u}}
246
247 \def\postheader{}
248 \ifundefined{documentclass}
249         \footline={\ifnum\pageno=1
250         {\smalltextfont\mudelacopyright\hfil \LilyIdString
251         }\else{\hfil\the\pageno\hfil}\fi
252 }\else
253         %% FIXME
254         \def\ps@plain{
255                 \renewcommand{\@oddhead}{}%
256                 \renewcommand{\@evenfoot}{}%
257                 \renewcommand{\@evenhead}{}%
258                 \renewcommand{\@oddfoot}{\ifnum\thepage=1
259         {\hfil \LilyIdString
260         }\else{foo\hfil\the\pageno\hfil}\fi}}
261         \def\ps@empty{
262                 \renewcommand{\@oddhead}{}%
263                 \renewcommand{\@evenfoot}{}%
264                 \renewcommand{\@evenhead}{}%
265                 \renewcommand{\@oddfoot}{\ifnum\thepage=1
266         {\hfil \LilyIdString
267         }\else{foo\hfil\the\pageno\hfil}\fi}}
268 \fi
269
270
271 % debugging stuff:
272 % \vbox to 0pt{\vskip .5cm \hruler{48}{3pt}\vss}