]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/lilypond-book.itely
5cb7d0d6d987f63556b48da8174846d95663199c
[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
15 @node lilypond-book manual
16 @chapter lilypond-book manual
17
18 If you want to add pictures of music to a document, you can simply do
19 it the way you would do with other types of pictures.  The pictures
20 are created separately, yielding PostScript pictures or PNG images,
21 and those are included into a La@TeX{} or HTML document.
22
23 @command{lilypond-book} provides a way to automate this process: this
24 program extracts snippets of music from your document, runs LilyPond
25 on them, and outputs the document with pictures substituted for the
26 music.  The line width and font size definitions for the music are
27 adjusted to match the layout of your document.
28
29 This procedure may be applied to La@TeX{}, @code{html} or Texinfo
30 documents.  A tutorial on using lilypond-book is in @ref{Integrating
31 text and music}.  For more information about La@TeX{}
32 @uref{http://www.ctan.org/tex-archive/info/lshort/english/,The not so
33 Short Introduction to LaTeX} provides a introduction to using La@TeX{}.
34
35
36
37
38 @menu
39 * Integrating Texinfo and music::  
40 * Integrating LaTeX and music::  
41 * Integrating HTML and music::  
42 * Music fragment options::      
43 * Invoking lilypond-book::      
44 @end menu
45
46
47
48 @cindex texinfo
49 @cindex latex
50 @cindex texinfo
51 @cindex @code{texi}
52 @cindex html
53 @cindex documents, adding music to
54
55
56 @node Integrating Texinfo and music
57 @section Integrating Texinfo and music
58
59 Music is specified like this:
60
61 @example
62 @@lilypond[options,go,here]
63   YOUR LILYPOND CODE
64 @@end lilypond
65 @@lilypond[options,go,here]@{ YOUR LILYPOND CODE @}
66 @@lilypondfile[options,go,here]@{@var{filename}@}
67 @end example
68
69 When lilypond-book is run on it, this results in a texinfo file. We
70 show two simple examples here.  First a complete block:
71
72 @example
73 @@lilypond[staffsize=26]
74   c' d' e' f' g'2 g'
75 @@end lilypond
76 @end example
77
78 @noindent
79 produces
80
81 @lilypond
82   c' d' e' f' g'2 g'
83 @end lilypond
84
85 Then the short version:
86
87 @example
88 @@lilypond[staffsize=11]@{<c' e' g'>@}
89 @end example
90
91 @noindent
92 produces
93
94 @lilypond[staffsize=11]{ <c' e' g'> }
95
96 When producing texinfo, lilypond-book also generates bitmaps of the
97 music, so you can make a HTML document with embedded music.
98
99 @c @TeX{} in node name seems to barf
100 @node Integrating LaTeX and music
101 @section Integrating LaTeX and music
102
103
104 For La@TeX{}, music is entered using
105
106 @example
107 \begin[options,go,here]@{lilypond@}
108   YOUR LILYPOND CODE
109 \end@{lilypond@}
110 @end example
111
112 @example
113 \lilypondfile[options,go,here]@{@var{filename}@}
114 @end example
115
116 @noindent
117 or
118
119 @example
120 \lilypond@{ YOUR LILYPOND CODE @}
121 @end example
122
123 Running lilypond-book yields a file that can be processed with
124 La@TeX{}.
125
126
127 We show some examples here:
128
129 @example
130 \begin[staffsize=26]@{lilypond@}
131   c' d' e' f' g'2 g'2
132 \end@{lilypond@}
133 @end example
134
135 @noindent
136 produces
137
138 @lilypond[staffsize=26]
139   c' d' e' f' g'2 g'2
140 @end lilypond
141
142 Then the short version:
143
144 @example
145 \lilypond[staffsize=11]@{<c' e' g'>@}
146 @end example
147
148 @noindent
149 produces
150
151 @lilypond[staffsize=11]{<c' e' g'>}
152
153 The linewidth of the music will be adjust by examining the commands in
154 the document preamble, the part of the document before
155 @code{\begin@{document@}}: @command{lilypond-book} sends these to
156 La@TeX{} to find out how wide the text is. The line width variable for
157 the music fragments are adjusted to the text width.
158
159 After @code{\begin@{document@}}, the column changing commands
160 @code{\onecolumn}, @code{\twocolumn} commands
161 @ignore 
162 and the
163 @code{multicols} environment from the multicol package
164 @end ignore
165 are also interpreted.
166
167 @cindex titling and lilypond-book
168 @cindex lilypond-book and titling
169 @cindex @code{\header} in La@TeX{} documents
170
171 The titling from the @code{\header} section of the fragments can be
172 imported by adding the following to the top of the La@TeX{} file:
173
174 @example
175 \input titledefs.tex
176 \def\preLilyPondExample@{\def\mustmakelilypondtitle@{@}@}
177 @end example
178
179 The music will be surrounded by @code{\preLilyPondExample} and
180 @code{\postLilyPondExample}, which are defined to be empty by default.
181
182 @cindex outline fonts
183 @cindex type1 fonts
184 @cindex dvips
185 @cindex invoking dvips
186
187 For printing the LaTeX document, you will need to use dvips. For
188 producing PostScript with scalable fonts, add the following options to
189 the dvips command line:
190 @example
191  -Ppdf -u +lilypond.map
192 @end example 
193
194 @noindent
195 PDF can then be produced with @code{ps2pdf}.
196
197 @cindex international characters
198 @cindex latin1
199
200 LilyPond does not use the LaTeX font handling scheme for lyrics and text
201 markups, so if you use non-anglosaxian characters in your lilypond-book
202 documents, include @code{\usepackage[latin1]@{inputenc@}} in the file
203 header but do not include @code{\usepackage[[T1]@{fontenc@}}. Character
204 sets other than latin1 are not supported directly but may be handled by
205 explicitly specifying the @code{font-name} property in LilyPond and
206 using the corresponding LaTeX packages. Please consult the mailing list
207 for more details.
208
209
210
211
212
213 @node Integrating HTML and music
214 @section Integrating HTML and music
215
216 Music is entered using
217
218 @example
219 <lilypond relative=1 verbatim>
220   \key c \minor r8 c16 b c8 g as c16 b c8 d | g,4
221 </lilypond>
222 @end example
223
224 @noindent
225 of which lilypond-book will produce a HTML with appropriate image tags for the
226 music fragments:
227  
228 @example
229 <lilypond relative=1 verbatim>
230   \key c \minor r8 c16 b c8 g as c16 b c8 d | g,4
231 </lilypond>
232 @end example
233
234 @lilypond[relative=1]
235   \key c \minor r8 c16 b c8 g as c16 b c8 d | g,4
236 @end lilypond
237
238 For inline pictures, use @code{<lilypond ... />} syntax, e.g.
239 @example
240 Some music in <lilypond a b c/> a line of text.
241 @end example
242
243 A special feature not (yet) available in other output formats, is the
244 @code{<lilypondfile>} tag, for example,
245 @example
246   <lilypondfile>trip.ly</lilypondfile>
247 @end example
248 This runs @file{trip.ly} through @code{lilypond} (see also
249 @ref{Invoking lilypond}), and substitutes a preview image in the
250 output. The image links to a separate HTML file, so clicking it will
251 take the viewer to a menu, with links to images, midi and printouts.
252
253 @cindex titling in THML
254 @cindex preview image
255 @cindex thumbnail
256
257 @node Music fragment options
258 @section Music fragment options
259
260 The commands for lilypond-book have room to specify one or more of the
261 following options:
262
263 @table @code
264 @item verbatim
265 @var{contents} is copied into the source, enclosed in a verbatim block;
266 followed by any text given with the @code{intertext} option; then
267 the actual music is displayed.  This option does not work with
268 the short version of the music blocks:
269
270 @code{ @@lilypond@{ CONTENTS @} } and @code{ \lilypond@{ CONTENTS @} }
271
272 @item filename=@var{filename}
273 name the file (for @code{printfilename} option). The argument should
274 be unquoted. 
275
276 @item staffsize=POINTS
277 @lilypond[staffsize=31.41592658]
278 \relative c' {
279   r16 c[ d e] f[ d e c] g'8[ c] b[\prall c] |
280   d16[ g, a b] c[ a b g] d'8[ g f\prall g]
281 }
282 @end lilypond
283
284 @item raggedright
285 produces naturally spaced lines (i.e., @code{raggedright = ##t}); this
286 works well for small music fragments.
287
288 @item linewidth=@var{size}\\@var{unit}
289 sets linewidth to @var{size}, where @var{unit} = cm, mm, in, or pt.
290 This option affects LilyPond output, not the text layout.
291
292 @item notime
293 prevents printing time signature.
294
295 @item fragment
296 @item nofragment
297 overrides @command{lilypond-book} auto detection of what type of code is
298 in the LilyPond block, voice contents, or complete code.
299
300 @item indent=@var{size}\\@var{unit}
301 sets indentation of the first music system to @var{size},
302 where @var{unit} = cm, mm, in, or pt.  This option affects LilyPond,
303 not the text layout.  For single-line fragments, the default is to
304 use no indentation.
305
306 For example
307 @example
308   \begin[indent=\\5cm,raggedright]@{lilypond@}
309   ...
310   \end@{lilypond@}
311 @end example
312
313
314 @item noindent
315 sets indentation of the first music system to zero.  This option
316 affects LilyPond, not the text layout.
317
318 @item texidoc
319 Includes the @code{texidoc} field, if defined in the file. This is
320 only for Texinfo output.
321
322 In Texinfo, the music fragment is normally preceded by the
323 @code{texidoc} field from the @code{\header}. The LilyPond test
324 documents are composed from small @file{.ly} files in this way:
325
326 @example
327   \header @{
328     texidoc = "this file demonstrates a single note"
329   @}
330   \score @{ \notes @{ c'4 @} @} 
331 @end example
332
333 @item relative, relative=@var{N}
334 uses relative octave mode.  By default, notes are specified relative
335 to central C.  The optional integer argument specifies the octave of the
336 starting note, where the default @code{1} is central C.
337 @end table
338
339
340 @node Invoking lilypond-book
341 @section Invoking lilypond-book
342
343
344 Running @command{lilypond-book} generates lots of small files that
345 LilyPond will process.  To avoid all that garbage in the source
346 directory, it is advisable to change to a temporary directory first:
347 @example
348 cd out && lilypond-book ../yourfile.tex
349 @end example
350
351 @noindent
352 or to use the @option{--output} command line option, and change to
353 that directory before running La@TeX{} or @file{makeinfo}:
354
355 @example
356 lilypond-book --output=out yourfile.lytex
357 cd out && latex yourfile.tex
358 @end example
359
360
361 @command{lilypond-book} accepts the following command line options:
362
363 @table @code
364 @item @option{-f @var{format}}, @option{--format=@var{format}}
365 Specify the document type to process: @code{html}, @code{latex} or
366 @code{texi} (the default).  @command{lilypond-book} usually figures this
367 out automatically.
368
369 The @code{texi} document type produces a texinfo file with music
370 fragments in the DVI output only. For getting images in the HTML
371 version,  the format 
372 @code{texi-html} must be used.
373
374 @item @option{-F @var{filter}}, @option{--filter=@var{filter}}
375 Pipe snippets through @var{filter}.
376
377 For example:
378 @example
379     lilypond-book --filter='convert-ly --from=2.0.0' my-book.tely
380 @end example
381
382 @item @option{--help}
383 Print a short help message.
384
385 @item @option{-I @var{dir}}, @option{--include=@var{dir}}
386 Add @var{DIR} to the include path.
387
388 @item @option{-o @var{dir}}, @option{--output=@var{dir}}
389 Place generated files in @var{dir}.
390
391 @item @option{-P @var{process}}, @option{--process=@var{COMMAND}}
392 Process lilypond snippets using @var{command}.  The default command is
393 @var{lilypond-bin}.
394
395 @item @option{--verbose}
396 Be verbose.
397
398 @item @option{--version}
399 Print version information.
400 @end table
401
402 For La@TeX{} input, the file to give to La@TeX{} has extension
403 @file{.latex}.  Texinfo input will be written to a file with extension
404 @file{.texi}.
405
406
407
408 @section Bugs
409
410 The La@TeX{} @code{\includeonly@{...@}} command is ignored.
411
412 The Texinfo command @code{pagesize} is not interpreted. Almost all
413 La@TeX{} commands that change margins and line widths are ignored.
414
415 Only the first @code{\score} of a LilyPond block is processed.
416
417 @c CHECKME--FIXME
418 The size of a music block is limited to 1.5 KB, due to technical
419 problems with the Python regular expression engine.  For longer files,
420 use @code{\lilypondfile}.
421
422 @command{lilypond-book} processes all music fragments in one big run.
423 The state of the GUILE interpreter is not reset between fragments;
424 this means that changes made to global GUILE definitions, e.g. done
425 with @code{set!} or @code{set-cdr!}, can leak from one fragment into
426 the next fragment.
427