]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/lilypond-book.itely
Various fixes for anal typechecking. ARGH--Ancient notation sucks
[lilypond.git] / Documentation / user / lilypond-book.itely
1 @c -*-texinfo-*-
2
3 @ignore
4
5 TODO: cleanup
6
7 ** AARGH.e We also have tutorial.itely: Integrating text and music.
8
9    Could also do with a cleanup.  Lost inspiration to fix this manual
10    where to describe what?
11
12 @end ignore
13
14 @node Integrating text and music with lilypond-book
15 @chapter Integrating text and music with lilypond-book
16
17 If you want to add pictures of music to a document, you can simply do
18 it the way you would do with other types of pictures.  You write
19 LilyPond code, process it separately to embedded PostScript or
20 @code{png}, and include it as a picture into your La@TeX{} or
21 @code{html} source.
22
23 @command{lilypond-book} provides you with a way to automate this
24 process: this program extracts snippets of music from your document,
25 runs lilypond on them, and substitutes the resulting pictures back.
26 The line width and font size definitions for the music are adjusted so
27 they match the layout of your document.
28
29 It can work on La@TeX{}, @code{html} or texinfo documents.  A tutorial
30 on using lilypond-book is in @ref{Integrating text and music}.
31
32 @menu
33 * Integrating Texinfo and music::  
34 * Integrating La@TeX{} and music::  
35 * Integrating HTML and music::  
36 * Music fragment options::      
37 * Invoking lilypond-book::      
38 @end menu
39
40
41 @cindex texinfo
42 @cindex latex
43 @cindex texinfo
44 @cindex @code{texi}
45 @cindex html
46 @cindex documents, adding music to
47
48
49 @node Integrating Texinfo and music
50 @section Integrating Texinfo and music
51
52 You specify the LilyPond code like this:
53 @example
54 @@lilypond[options, go, here]
55   YOUR LILYPOND CODE
56 @@end lilypond
57 @@lilypond[option, go, here]@{ YOUR LILYPOND CODE @}
58 @@lilypondfile[options, go,here]@{@var{filename}@}
59 @end example
60
61 We show two simple examples here. First a complete block:
62 @example
63 @@lilypond[26pt]
64 c' d' e' f' g'2 g'
65 @@end lilypond
66 @end example
67
68 produces this music:
69 @lilypond
70 c' d' e' f' g'2 g'
71 @end lilypond
72
73 Then the short version:
74 @example
75 @@lilypond[11pt]@{<c' e' g'>@}
76 @end example
77
78 and its music:
79
80 @lilypond[11pt]{<c' e' g'>}
81
82 @command{lilypond-book} knows the default margins, and a few paper
83 sizes. One of these commands should be in the beginning of the document:
84 @itemize @bullet
85 @item @code{@@afourpaper}
86 @item @code{@@afourlatex}
87 @item @code{@@afourwide}
88 @item @code{@@smallbook}
89 @end itemize
90 @code{@@pagesizes} are not yet supported.
91
92 When producing texinfo, lilypond-book also generates bitmaps of the
93 music, so you can make a HTML document with embedded music.
94
95 @node Integrating La@TeX{} and music
96 @section Integrating La@TeX{} and music
97
98 You specify the LilyPond code like this:
99 @example
100 \begin[option, go, here]@{lilypond@}
101  YOUR LILYPOND CODE
102 \end@{lilypond@}
103 @end example
104
105 @example
106 \lilypondfile[options, go,here]@{@var{filename}@}
107 @end example
108 or 
109 @example
110 \lilypond@{ YOUR LILYPOND CODE @}
111 @end example
112
113 We show some examples here.
114
115 @example
116 \begin[26pt]@{lilypond@}
117 c' d' e' f' g'2 g'2
118 \end@{lilypond@}
119 @end example
120
121 produces this music:
122
123 @lilypond[26pt]
124 c' d' e' f' g'2 g'2
125 @end lilypond
126
127 Then the short version:
128 @example
129 \lilypond[11pt]@{<c' e' g'>@}
130 @end example
131
132 and its music:
133
134 @lilypond[11pt]{<c' e' g'>}
135
136
137 You can use whatever commands you like in the document preamble,
138 that is the part of the document before @code{\begin@{document@}}.
139 @command{lilypond-book} will send it to La@TeX{} to find out how wide
140 the text is and adjust the linewidth variable in the paper definition of
141 you music according to that.
142
143 After @code{\begin@{document@}} you must be a little more careful
144 when you use commands that change the width of the text and how
145 many columns there are. @command{lilypond-book} know about the
146 @code{\onecolumn} and @code{\twocolumn} commands and the @code{multicols}
147 environment from the multicol package.
148
149 The music will be surrounded by @code{\preLilypondExample} and
150 @code{\postLilypondExample}. The variables are 
151 defined to nothing by default, and the user can redefine them
152 to whatever he wants.
153
154
155 @node Integrating HTML and music
156 @section Integrating HTML and music
157
158 You specify the LilyPond code like this:
159
160 @quotation
161 @example
162 <lilypond relative1 verbatim>
163   \key c \minor r8 c16 b c8 g as c16 b c8 d | g,4
164 </lilypond> 
165 @end example
166 @end quotation
167
168 produces
169
170 @quotation
171 @example
172 <lilypond relative1 verbatim>
173   \key c \minor r8 c16 b c8 g as c16 b c8 d | g,4
174 </lilypond> 
175 @end example
176 @lilypond[relative1]
177   \key c \minor r8 c16 b c8 g as c16 b c8 d | g,4
178 @end lilypond
179 @end quotation
180
181 Inline picture:
182
183 @quotation
184 @example
185 Some music in <lilypond a b c/> a line of text.
186 @end example
187 @end quotation
188
189 @node Music fragment options
190 @section Music fragment options
191
192 The commands for lilypond-book have room to specify options. These are
193 all of the options:
194
195 @table @code
196 @item eps
197 This will create the music as eps graphics and include it into the
198 document with the @code{\includegraphics} command. It works in
199 La@TeX{} only.
200
201 This enables you to place music examples in the running text (and not in
202 a separate paragraph). To avoid that La@TeX{} places the music on a line
203 of its own, there should be no empty lines between the normal text and
204 the LilyPond environment. For inline music, you probably also need a
205 smaller music font size (eg. 11 pt or 13 pt) 
206
207
208 @item verbatim
209     CONTENTS is copied into the source enclosed in a verbatim block,
210     followed by any text given with the @code{intertext} option, then
211     the actual music is displayed. This option does not work with
212     the short version of the LilyPond blocks:
213
214     @code{ @@lilypond@{ CONTENTS @} } and @code{ \lilypond@{ CONTENTS @} }
215
216 @item smallverbatim
217       like @code{verbatim}, but in a smaller font.
218
219 @item intertext="@var{text}"
220     Used in conjunction with @code{verbatim} option: this puts
221 @var{text} between the code and the music.
222 @item filename="@var{filename}"
223     Save the LilyPond code to @var{filename}. By default, a hash value
224 of the code is used.
225
226 @item @code{11pt}
227 @lilypond[11pt, eps]
228   \relative c'{
229     r16 [c d e][f d e c] [g'8 c][b-\prall c] |
230     [d16 g, a b][c a b g][d'8 g f-\prall g]
231   }
232 @end lilypond
233 @item @code{13pt}
234 @lilypond[13pt, eps]
235   \relative c'{
236     r16 [c d e][f d e c] [g'8 c][b-\prall c] |
237     [d16 g, a b][c a b g][d'8 g f-\prall g]
238   }
239 @end lilypond
240 @item @code{16pt}
241 @lilypond[16pt, eps]
242   \relative c'{
243     r16 [c d e][f d e c] [g'8 c][b-\prall c] |
244     [d16 g, a b][c a b g][d'8 g f-\prall g]
245   }
246 @end lilypond
247 @item @code{20pt}
248 @lilypond[20pt, eps]
249   \relative c'{
250     r16 [c d e][f d e c] [g'8 c][b-\prall c] |
251     [d16 g, a b][c a b g][d'8 g f-\prall g]
252   }
253 @end lilypond
254 @item @code{26pt}
255 @lilypond[26pt, eps]
256   \relative c'{
257     r16 [c d e][f d e c] [g'8 c][b-\prall c] |
258   }
259 @end lilypond
260
261 @item singleline
262   Produce a single naturally spaced, unjustified line. (i.e.: linewidth = -1).
263 @item multiline
264   The opposite of @code{singleline}: justify and break lines.
265 @item linewidth=@var{size}@var{unit}
266     Set linewidth to @var{size}, where @var{unit} = cm, mm, in or pt.
267 @item fragment
268 @item nofragment
269     Override @command{lilypond-book} auto detection of what type of code is in the
270     LilyPond block, voice contents or complete code.
271 @item indent=@var{size}@var{unit}
272     Set first line indent to @var{size}, where @var{unit} = cm, mm, in or pt.
273 @item noindent
274     Set first line indent to zero.
275 @item printfilename
276     Prints the file name before the music example. Useful in conjunction
277 with @code{\lilypondfile}.
278 @item relative, relative @var{N}
279     Use relative octave mode. By default, notes are specified relative 
280     central C. The optional integer argument specifies how many octaves 
281     higher (positive number) or lower (negative number) to place the 
282     starting note.
283 @end table
284
285 @node Invoking lilypond-book
286 @section Invoking lilypond-book
287
288 When you run @command{lilypond-book} it will generate lots of small
289 files that LilyPond will process. So to avoid all the garbage in
290 your source directory, you should either change to a temporary
291 directory, or use the @code{--outdir} command line options:
292
293 @code{cd out && lilypond-book ../yourfile.tex}
294
295 @code{lilypond-book --outdir=out yourfile.tex}
296
297
298 For latex input, the file to give to latex has extension @file{.latex}.
299 Texinfo input will be written to a file with extension @file{.texi}.
300
301 If you use @code{--outdir}, you should also @code{cd} to that directory
302 before running LaTeX or makeinfo. This may seem a little kludgey, but
303 both Latex and makeinfo expect picture files (the music) to be in the
304 current working directory. Moreover, if you do this, LaTeX will not
305 clutter you normal working directory  with output files.
306
307 @cindex titling and lilypond-book
308 @cindex lilypond-book and titling
309 @cindex \header in LaTeX documents
310
311 If you want to add titling from the @code{\header} section of the
312 files, you should add  the following to the top of your LaTeX
313 @example
314 \input titledefs.tex
315 \def\preLilypondExample@{\def\mustmakelilypondtitle@{@}@}
316 @end example
317
318 lilypond-book accepts the following command-line options: 
319 @table @code
320 @item @option{-f}, @option{--format=}
321     Specify the document type to process: @code{html}, @code{latex} or
322 @code{texi} (default).  @command{lilypond-book} usually figures this
323 out automatically.
324
325 @item --default-music-fontsize=@var{sz}pt
326     Set the fontsize to use for LilyPond if no fontsize is given
327     as option.
328 @item --force-music-fontsize=@var{sz}pt
329     Force all LilyPond to use this fontsize, overriding options
330     given to @code{\begin@{lilypond@}}
331 @item -I @var{DIR}, --include=@var{DIR}
332     Add @var{DIR} to the include path.
333 @item -M, --dependencies
334         Write dependencies to @file{filename.dep}
335 @item --dep-prefix=@code{PREF}
336         prepend @code{PREF} before each @code{-M} dependency
337 @item -n, --no-lily
338         don't run LilyPond, but do generate the @code{.ly} files
339 @item --no-music
340         strip all  LilyPond blocks from the file.
341 @item --no-pictures
342         don't generate pictures when processing Texinfo.
343 @item --read-lys
344         don't write ly files. This way you can do
345 @example
346  lilypond-book file.tely
347  convert-ly
348  lilypond-book --read-lys
349 @end example
350
351 @item --outname=@var{FILE}
352     The name of La@TeX{} file to output. If this option  is not given,
353     the output name is derived from the input name.
354 @item --outdir=@var{DIR}
355          place generated files in @var{DIR}.
356 @item --version
357         print version information
358 @item --help
359         Print a short help message
360 @end table
361
362
363 @section Bugs
364   
365 The La@TeX{} \includeonly@{...@} command is ignored.
366
367 The Texinfo command @code{pagesize} is on the TODO list for LilyPond
368 1.6, but changing the linewidth in other ways will not give you a
369 straight right margin.
370
371 Almost all La@TeX{} commands that change margins and line widths are
372 ignored.
373
374 There is no way to automatically apply convert-ly only to fragments
375 inside a lilypond-book file.
376
377 @file{lilypond-book} processes all music fragments in one big run. The
378 state of the GUILE interpreter is not reset between fragments; this
379 means that global GUILE definitions, eg. done with @code{#(define
380 .. )} and @code{#(set! .. )} can leak from one fragment into a next
381 fragment.