]> git.donarmstrong.com Git - lilypond.git/blob - tex/lilyponddefs.tex
* scripts/lilypond.py: Remove LaTeX titling kludge. Remove page
[lilypond.git] / tex / lilyponddefs.tex
1 %%% lilyponddefs.tex -- TeX macros for LilyPond output.
2 %%%
3 %%%  source file of the GNU LilyPond music typesetter
4 %%% 
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>
8 %%%
9 %% Avoid \par while reading this file.
10 \edef\lilyponddefsELC{\the\endlinechar}%
11 \endlinechar -1\relax
12
13 %% This runs with plain TeX, LaTeX, pdftex, and texinfo.
14 %%
15 %% To avoid interferences, lilyponddefs.tex must be loaded within a group.
16 %% It is loaded only once, so the definitions must be global.
17 %%
18 %% The overall structure of a file created by LilyPond is as follows:
19 %%
20 %%   <lilypond parameter definitions>
21 %%   \ifx\lilypondstart \undefined
22 %%     \input lilyponddefs
23 %%   \fi
24 %%   \lilypondstart
25 %%   <font setup and note output>
26 %%   \lilypondend
27
28 \newdimen\outputscale
29
30 %% Handy macros from the LaTeX manual.
31 \long\gdef\lilypondfirst#1#2{#1}
32 \long\gdef\lilypondsecond#1#2{#2}
33 \gdef\lilypondifundefined#1{
34   \expandafter\ifx\csname#1\endcsname\relax
35     \expandafter\lilypondfirst
36   \else
37     \expandafter\lilypondsecond
38   \fi
39 }
40
41 \gdef\lilypondstart{
42   \begingroup
43   \catcode `\@=11\relax
44   %% \@nodocument is defined as \relax after `\begin{document}'
45   \lilypondifundefined{@nodocument}
46     {
47       %% either plain TeX or texinfo or not at the beginning of LaTeX input
48       \def\x{\endgroup}}
49     {
50       %% FIXME: a4
51       %% provide a proper LaTeX preamble (for A4 paper format)
52       \def\x{
53         \endgroup
54         \def\lilyponddocument{}
55         \documentclass[a4paper]{article}
56         %% safe-mode
57         \nofiles
58         %% Nullify [La]TeX page layout settings, page layout by LilyPond.
59         \pagestyle{empty}
60         \topmargin-1in
61         %% FIXME: empirical computer science: page is ca 5mm too low.
62         \advance\topmargin-5mm
63         \headheight0pt\headsep0pt
64         \oddsidemargin-1in
65         \evensidemargin\oddsidemargin
66         \parindent 0pt
67         %% TEXINFO workaround: \begin is defined as \outer, use \csname.
68         \csname begin\endcsname{document}}}
69   \x}
70
71 \gdef\lilypondend{
72   \lilypondifundefined{lilypondbook}
73   {\lilypondifundefined{lilypondpaperlastpagefill}
74     {\vskip 0pt plus\lilypondpaperinterscorelinefill00 fill}
75     {}}
76   {}
77   \begingroup
78   \lilypondifundefined{lilyponddocument}
79     {\def\x{\endgroup}}
80     {\def\x{\endgroup\csname end\endcsname{document}}}
81   \x}
82
83 %% Inversed \loop ... \repeat macro
84 \def\lilypondloop#1\lilypondrepeat{
85   \def\lilypondbody{#1}
86   \lilyponditerate
87 }
88
89 \def\lilyponditerate{
90   % \if ...
91     \lilypondbody
92     \let\lilypondnext \relax
93   \else
94     \let\lilypondnext \lilyponditerate
95   \fi
96   \lilypondnext
97 }
98
99 %% Include \special only once.
100 \gdef\lilypondspecial{
101   \special{header=music-drawing-routines.ps}
102   \gdef\lilypondspecial{}
103 }
104
105 %% The feta characters.
106 \input feta20
107
108 \global\font\fetasixteen = feta16
109 \gdef\fetafont{\fetasixteen}
110 \gdef\fetachar#1{\hbox{\fetasixteen#1}}
111
112 \gdef\topalign#1{\vbox to 0pt{\hbox{#1}\vss}}
113 \gdef\leftalign#1{\hbox to 0pt{#1\hss}}
114
115 \gdef\lyitem#1#2#3{
116   \topalign{\raise#2\outputscale\leftalign{\kern#1\outputscale#3}}}
117
118 \gdef\XXXlybox#1#2#3#4#5{
119   \vbox to #4\outputscale{
120     \hbox to #3\outputscale{
121       \leftalign{\kern#1\outputscale\lower#2\outputscale\topalign{#5}}}
122     \hss}\vss}
123
124 %% FIXME: no dimensions, should fix at toplevel
125 \gdef\lybox#1#2#3#4#5{
126   \leftalign{\kern#1\outputscale\lower#2\outputscale\topalign{#5}}}
127
128 \gdef\lyvrule#1#2#3#4{
129   \kern#1\outputscale
130   \vrule width #2\outputscale depth #3\outputscale height #4\outputscale}
131
132 \lilypondifundefined{lilypondpaperinterscorelinefill}
133   {\gdef\lilypondpaperinterscorelinefill{0}}
134   {\gdef\lilypondpaperinterscorelinefill{1}}
135
136 %% Allow overriding of interscoreline, e.g. for lilypond.py's --preview
137 \lilypondifundefined{interscoreline}
138 {\gdef\interscoreline{}}{}
139
140 %% Include postscript definitions unless using PDFTeX,
141 %% in that case use pdf definitions.
142 %% MiKTeX workaround: use \csname.
143 \lilypondifundefined{lilypondpostscript}
144 {\lilypondifundefined{pdfoutput}
145   {\input lily-ps-defs }
146   {\pdfoutput = 1
147     \input lily-pdf-defs }}
148 {}
149
150 %% Restore newline functionality (disabled to avoid \par).
151 \endlinechar \lilyponddefsELC
152 \endinput
153
154 %% end lilyponddefs.tex