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 introduction 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:
73 @@lilypond[staffsize=26]
85 Then the short version:
88 @@lilypond[staffsize=11]@{<c' e' g'>@}
94 @lilypond[fragment,staffsize=11]{ <c' e' g'> }
96 When producing texinfo, lilypond-book also generates bitmaps of the
97 music, so you can make a HTML document with embedded music.
99 @c @TeX{} in node name seems to barf
100 @node Integrating LaTeX and music
101 @section Integrating LaTeX and music
104 For La@TeX{}, music is entered using
107 \begin[options,go,here]@{lilypond@}
113 \lilypondfile[options,go,here]@{@var{filename}@}
120 \lilypond@{ YOUR LILYPOND CODE @}
123 Running lilypond-book yields a file that can be processed with
127 We show some examples here:
130 \begin[staffsize=26]@{lilypond@}
138 @lilypond[fragment,staffsize=26]
142 Then the short version:
145 \lilypond[staffsize=11]@{<c' e' g'>@}
151 @lilypond[fragment,staffsize=11]{<c' e' g'>}
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.
159 After @code{\begin@{document@}}, the column changing commands
160 @code{\onecolumn}, @code{\twocolumn} commands
163 @code{multicols} environment from the multicol package
165 are also interpreted.
167 @cindex titling and lilypond-book
168 @cindex @code{\header} in La@TeX{} documents
171 The music will be surrounded by @code{\preLilyPondExample} and
172 @code{\postLilyPondExample}, which are defined to be empty by default.
174 @cindex outline fonts
177 @cindex invoking dvips
179 For printing the LaTeX document, you will need to use dvips. For
180 producing PostScript with scalable fonts, add the following options to
181 the dvips command line:
183 -Ppdf -u +lilypond.map
187 PDF can then be produced with @code{ps2pdf}.
189 @cindex international characters
192 LilyPond does not use the LaTeX font handling scheme for lyrics and text
193 markups, so if you use characters in your lilypond-book
194 documents that are not included in the standard US-ASCII character set,
195 include @code{\usepackage[latin1]@{inputenc@}} in the file
196 header but do not include @code{\usepackage[[T1]@{fontenc@}}. Character
197 sets other than latin1 are not supported directly but may be handled by
198 explicitly specifying the @code{font-name} property in LilyPond and
199 using the corresponding LaTeX packages. Please consult the mailing list
206 @node Integrating HTML and music
207 @section Integrating HTML and music
209 Music is entered using
212 <lilypond relative=1 verbatim>
213 \key c \minor r8 c16 b c8 g as c16 b c8 d | g,4
218 of which lilypond-book will produce a HTML with appropriate image tags for the
222 <lilypond relative=2 verbatim>
223 \key c \minor r8 c16 b c8 g as c16 b c8 d | g,4
227 @lilypond[fragment,relative=2]
228 \key c \minor r8 c16 b c8 g as c16 b c8 d | g,4
231 For inline pictures, use @code{<lilypond ... />} syntax, e.g.
233 Some music in <lilypond a b c/> a line of text.
236 A special feature not (yet) available in other output formats, is the
237 @code{<lilypondfile>} tag, for example,
239 <lilypondfile>trip.ly</lilypondfile>
241 This runs @file{trip.ly} through @code{lilypond} (see also
242 @ref{Invoking lilypond}), and substitutes a preview image in the
243 output. The image links to a separate HTML file, so clicking it will
244 take the viewer to a menu, with links to images, midi and printouts.
246 @cindex titling in THML
247 @cindex preview image
250 @node Music fragment options
251 @section Music fragment options
253 The commands for lilypond-book have room to specify one or more of the
258 @var{contents} is copied into the source, enclosed in a verbatim block;
259 followed by any text given with the @code{intertext} option; then
260 the actual music is displayed. This option does not work with
261 the short version of the music blocks:
263 @code{ @@lilypond@{ CONTENTS @} } and @code{ \lilypond@{ CONTENTS @} }
265 @item filename=@var{filename}
266 This names the file for the @code{printfilename} option. The argument
269 @item staffsize=@var{ht}
270 Sets the staff height to @var{ht}, which is measured in points.
273 produces naturally spaced lines (i.e., @code{raggedright = ##t}); this
274 works well for small music fragments.
276 @item linewidth=@var{size}\@var{unit}
277 sets linewidth to @var{size}, where @var{unit} = cm, mm, in, or pt.
278 This option affects LilyPond output, not the text layout.
281 prevents printing time signature.
285 overrides @command{lilypond-book} auto detection of what type of code is
286 in the LilyPond block, voice contents, or complete code.
288 @item indent=@var{size}\@var{unit}
289 sets indentation of the first music system to @var{size},
290 where @var{unit} = cm, mm, in, or pt. This option affects LilyPond,
291 not the text layout. For single-line fragments, the default is to
296 \begin[indent=5\cm,raggedright]@{lilypond@}
303 sets indentation of the first music system to zero. This option
304 affects LilyPond, not the text layout.
307 sets linewidth to the width of a quotation and puts the output
308 in a quotation block.
311 Includes the @code{texidoc} field, if defined in the file. This is
312 only for Texinfo output.
314 In Texinfo, the music fragment is normally preceded by the
315 @code{texidoc} field from the @code{\header}. The LilyPond test
316 documents are composed from small @file{.ly} files in this way:
320 texidoc = "this file demonstrates a single note"
322 \score @{ \notes @{ c'4 @} @}
325 @item relative, relative=@var{N}
326 uses relative octave mode. By default, notes are specified relative
327 to middle C. The optional integer argument specifies the octave of the
328 @item relative, relative=@var{N}
329 uses relative octave mode. By default, notes are specified relative
330 to middle C. The optional integer argument specifies the octave of the
331 starting note, where the default @code{1} is middle C.
335 @node Invoking lilypond-book
336 @section Invoking lilypond-book
339 Running @command{lilypond-book} generates lots of small files that
340 LilyPond will process. To avoid all that garbage in the source
341 directory use the @option{--output} command line option, and change to
342 that directory before running La@TeX{} or @file{makeinfo}:
345 lilypond-book --output=out yourfile.lytex
346 cd out && latex yourfile.tex
350 @command{lilypond-book} accepts the following command line options:
353 @item @option{-f @var{format}}, @option{--format=@var{format}}
354 Specify the document type to process: @code{html}, @code{latex} or
355 @code{texi} (the default). @command{lilypond-book} figures this
358 The @code{texi} document type produces a texinfo file with music
359 fragments in the DVI output only. For getting images in the HTML
361 @code{texi-html} must be used.
363 @item @option{-F @var{filter}}, @option{--filter=@var{filter}}
364 Pipe snippets through @var{filter}.
368 lilypond-book --filter='convert-ly --from=2.0.0' my-book.tely
371 @item @option{--help}
372 Print a short help message.
374 @item @option{-I @var{dir}}, @option{--include=@var{dir}}
375 Add @var{DIR} to the include path.
377 @item @option{-o @var{dir}}, @option{--output=@var{dir}}
378 Place generated files in @var{dir}.
380 @item @option{-P @var{process}}, @option{--process=@var{COMMAND}}
381 Process lilypond snippets using @var{command}. The default command is
384 @item @option{--verbose}
387 @item @option{--version}
388 Print version information.
391 For La@TeX{} input, the file to give to La@TeX{} has extension
392 @file{.latex}. Texinfo input will be written to a file with extension
399 The La@TeX{} @code{\includeonly@{...@}} command is ignored.
401 The Texinfo command @code{pagesize} is not interpreted. Almost all
402 La@TeX{} commands that change margins and line widths are ignored.
404 Only the first @code{\score} of a LilyPond block is processed.
407 The size of a music block is limited to 1.5 KB, due to technical
408 problems with the Python regular expression engine. For longer files,
409 use @code{\lilypondfile}.