7 ** AARGH.e We also have tutorial.itely: Integrating text and music.
9 Could also do with a cleanup. Lost inspiration to fix this manual
10 where to describe what?
15 @node lilypond-book manual
16 @chapter lilypond-book manual
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.
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.
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 introction to using La@TeX{}.
39 * Integrating Texinfo and music::
40 * Integrating LaTeX and music::
41 * Integrating HTML and music::
42 * Music fragment options::
43 * Invoking lilypond-book::
53 @cindex documents, adding music to
56 @node Integrating Texinfo and music
57 @section Integrating Texinfo and music
59 Music is specified like this:
62 @@lilypond[options, go, here]
65 @@lilypond[options, go, here]@{ YOUR LILYPOND CODE @}
66 @@lilypondfile[options, go, here]@{@var{filename}@}
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:
85 Then the short version:
88 @@lilypond[11pt]@{<<c' e' g'>>@}
94 @lilypond[11pt]{ <<c' e' g'>> }
96 @command{lilypond-book} knows the default margins and a few paper
97 sizes. One of these commands should be in the beginning of the document:
100 @item @code{@@afourpaper}
101 @item @code{@@afourlatex}
102 @item @code{@@afourwide}
103 @item @code{@@smallbook}
107 @code{@@pagesizes} are not yet supported.
109 When producing texinfo, lilypond-book also generates bitmaps of the
110 music, so you can make a HTML document with embedded music.
113 @c @TeX{} in node name seems to barf
114 @node Integrating LaTeX and music
115 @section Integrating LaTeX and music
118 For La@TeX{}, music is entered using
121 \begin[options, go, here]@{lilypond@}
127 \lilypondfile[options, go,here]@{@var{filename}@}
134 \lilypond@{ YOUR LILYPOND CODE @}
137 Running lilypond-book yields a file that can be processed with
138 La@TeX{}. We show some examples here:
141 \begin[26pt]@{lilypond@}
153 Then the short version:
156 \lilypond[11pt]@{<<c' e' g'>>@}
162 @lilypond[11pt]{<<c' e' g'>>}
164 The linewidth of the music will be adjust by examining the commands in
165 the document preamble, the part of the document before
166 @code{\begin@{document@}}: @command{lilypond-book} sends these to
167 La@TeX{} to find out how wide the text is. The line width variable for
168 the music fragments are adjusted to the text width.
170 After @code{\begin@{document@}}, the column changing commands
171 @code{\onecolumn} , @code{\twocolumn} commands and the
172 @code{multicols} environment from the multicol package are also
175 The titling from the @code{\header} section of the fragments can be
176 imported by adding the following to the top of the La@TeX{} file:
180 \def\preLilyPondExample@{\def\mustmakelilypondtitle@{@}@}
183 The music will be surrounded by @code{\preLilyPondExample} and
184 @code{\postLilyPondExample}, which are defined to be empty by default.
186 @node Integrating HTML and music
187 @section Integrating HTML and music
189 Music is entered using
192 <lilypond relative1 verbatim>
193 \key c \minor r8 c16 b c8 g as c16 b c8 d | g,4
198 of which lilypond-book will produce a HTML with appropriate image tags for the
202 <lilypond relative1 verbatim>
203 \key c \minor r8 c16 b c8 g as c16 b c8 d | g,4
208 \key c \minor r8 c16 b c8 g as c16 b c8 d | g,4
211 For inline pictures, use @code{<lilypond ... />} syntax, eg.
213 Some music in <lilypond a b c/> a line of text.
216 A special feature not (yet) available in other output formats, is the
217 @code{<ly2dvifile>} tag, for example,
219 <ly2dvifile>trip.ly</ly2dvifile>
221 This runs @file{trip.ly} through ly2dvi (see also @ref{Invoking
222 ly2dvi}), and substitutes a preview image in the output. The image
223 links to a separate HTML file, so clicking it will take the viewer to
224 a menu, with links to images, midi and printouts.
227 @cindex titling in THML
228 @cindex preview image
231 @node Music fragment options
232 @section Music fragment options
234 The commands for lilypond-book have room to specify one or more of the
239 CONTENTS is copied into the source enclosed in a verbatim block,
240 followed by any text given with the @code{intertext} option, then
241 the actual music is displayed. This option does not work with
242 the short version of the music blocks:
244 @code{ @@lilypond@{ CONTENTS @} } and @code{ \lilypond@{ CONTENTS @} }
247 works like @code{verbatim}, but in a smaller font.
249 @item intertext="@var{text}"
250 is used in conjunction with @code{verbatim} option: This puts
251 @var{text} between the code and the music (without indentation).
253 @item filename="@var{filename}"
254 saves the LilyPond code to @var{filename}. By default, a hash value
260 r16 c[ d e] f[ d e c] g'8[ c] b[\prall c] |
261 d16[ g, a b] c[ a b g] d'8[ g f\prall g]
268 r16 c[ d e] f[ d e c] g'8[ c] b[\prall c] |
269 d16[ g, a b] c[ a b g] d'8[ g f\prall g]
276 r16 c[ d e] f[ d e c] g'8[ c] b[\prall c] |
283 r16 [c d e][f d e c] [g'8 c][b-\prall c] |
290 r16 c[ d e] f[ d e c] g'8[ c] b[\prall c] |
295 produces naturally spaced lines (i.e., @code{raggedright = ##t}); this
296 works well for small music fragments.
299 is the opposite of @code{singleline}: it justifies and breaks lines.
301 @item linewidth=@var{size}@var{unit}
302 sets linewidth to @var{size}, where @var{unit} = cm, mm, in, or pt.
303 This option affects LilyPond output, not the text layout.
306 prevents printing time signature.
310 overrides @command{lilypond-book} auto detection of what type of code is
311 in the LilyPond block, voice contents or complete code.
313 @item indent=@var{size}@var{unit}
314 sets indentation of the first music system to @var{size},
315 where @var{unit} = cm, mm, in, or pt. This option affects LilyPond,
316 not the text layout. For single-line fragments the default is to
320 sets indentation of the first music system to zero. This option
321 affects LilyPond, not the text layout.
324 prevents including @code{texidoc}. This is only for Texinfo output.
326 In Texinfo, the music fragment is normally preceded by the
327 @code{texidoc} field from the @code{\header}. The LilyPond test
328 documents are composed from small @file{.ly} files in this way:
332 texidoc = "this file demonstrates a single note"
334 \score @{ \notes @{ c'4 @} @}
338 instructs @command{lilypond-book} to put La@TeX{} and Texinfo output
339 into a quotation block.
342 prints the file name before the music example. Useful in conjunction
343 with @code{\lilypondfile}.
345 @item relative, relative @var{N}
346 uses relative octave mode. By default, notes are specified relative
347 central C. The optional integer argument specifies the octave of the
348 starting note, where the default @code{1} is central C.
352 @node Invoking lilypond-book
353 @section Invoking lilypond-book
355 Running @command{lilypond-book} generates lots of small files that
356 LilyPond will process. To avoid all that garbage in the source
357 directory, it is advisable to change to a temporary directory first:
359 cd out && lilypond-book ../yourfile.tex
363 or to use the @option{--outdir} command line option, and change to
364 that director before running La@TeX{} or @file{makeinfo}:
367 lilypond-book --outdir=out yourfile.tex
368 cd out && latex yourfile.latex
371 For La@TeX{} input, the file to give to La@TeX{} has extension @file{.latex}.
372 Texinfo input will be written to a file with extension @file{.texi}.
374 @cindex titling and lilypond-book
375 @cindex lilypond-book and titling
376 @cindex @code{\header} in La@TeX{} documents
378 To add titling from the @code{\header} section of the files, add the
379 following to the top of the La@TeX{} file:
382 \def\preLilyPondExample@{\def\mustmakelilypondtitle@{@}@}
385 @cindex outline fonts
388 @cindex invoking dvips
390 For printing the LaTeX document, you will need to use dvips. For
391 producing PS with scalable fonts, add the following options to the dvips
394 -Ppdf -u +lilypond.map
399 @command{lilypond-book} accepts the following command line options:
402 @item @option{-f @var{format}}, @option{--format=@var{format}}
403 Specify the document type to process: @code{html}, @code{latex} or
404 @code{texi} (the default). @command{lilypond-book} usually figures this
407 The @code{texi} document type produces a texinfo file with music
408 fragments in the DVI output only. For getting images in the HTML
410 @code{texi-html} must be used.
412 @item @option{--default-music-fontsize=@var{sz}pt}
413 Set the music font size to use if no fontsize is given as option.
415 @item @option{--force-music-fontsize=@var{sz}pt}
416 Force all music to use this fontsize, overriding options given to
417 @code{\begin@{lilypond@}}.
419 @item @option{-I @var{dir}}, @option{--include=@var{dir}}
420 Add @var{DIR} to the include path.
422 @item @option{-M}, @option{--dependencies}
423 Write dependencies to @file{filename.dep}.
425 @item @option{--dep-prefix=@var{pref}}
426 Prepend @var{pref} before each @option{-M} dependency.
428 @item @option{-n}, @option{--no-lily}
429 Generate the @code{.ly} files, but do not process them.
431 @item @option{--no-music}
432 Strip all music from the input file.
434 @item @option{--no-pictures}
435 Do not generate pictures when processing Texinfo.
437 @item @option{--outname=@var{file}}
438 The name of La@TeX{} file to output. If this option is not given,
439 the output name is derived from the input name.
441 @item @option{--outdir=@var{dir}}
442 Place generated files in @var{dir}.
444 @item @option{--version}
445 Print version information.
447 @item @option{--help}
448 Print a short help message.
455 The La@TeX{} @code{\includeonly@{...@}} command is ignored.
457 The Texinfo command @code{pagesize} is not interpreted. Almost all
458 La@TeX{} commands that change margins and line widths are ignored.
460 The size of a music block is limited to 1.5 kb, due to technical
461 problems with the Python regular expression engine. For longer files,
462 use @code{\lilypondfile}. Using @code{\lilypondfile} also makes
463 upgrading files (through convert-ly, see @ref{Invoking convert-ly})
466 @command{lilypond-book} processes all music fragments in one big run.
467 The state of the GUILE interpreter is not reset between fragments;
468 this means that changes made to global GUILE definitions, e.g. done
469 with @code{set!} or @code{set-cdr!}, can leak from one fragment into