]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/lilypond-book.itely
Book parts: \bookpart implementation
[lilypond.git] / Documentation / user / lilypond-book.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond-program.tely
3 @ignore
4     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
5
6     When revising a translation, copy the HEAD committish of the
7     version that you are working on.  See TRANSLATION for details.
8 @end ignore
9
10 @c \version "2.11.61"
11
12 @c Note: keep this node named so that `info lilypond-book' brings you here.
13 @node LilyPond-book
14 @chapter @command{lilypond-book}: Integrating text and music
15
16 If you want to add pictures of music to a document, you can simply do it
17 the way you would do with other types of pictures.  The pictures are
18 created separately, yielding PostScript output or PNG images, and those
19 are included into a @LaTeX{} or HTML document.
20
21 @command{lilypond-book} provides a way to automate this process: This
22 program extracts snippets of music from your document, runs
23 @command{lilypond} on them, and outputs the document with pictures
24 substituted for the music.  The line width and font size definitions for
25 the music are adjusted to match the layout of your document.
26
27 This is a separate program from @command{lilypond} itself, and is run
28 on the command line; for more information, see @ref{Command-line
29 usage}.  If you have MacOS 10.3 or 10.4 and you have trouble running
30 @code{lilypond-book}, see @ref{Setup for MacOS X}.
31
32 This procedure may be applied to @LaTeX{}, HTML, Texinfo or DocBook
33 documents.
34
35 @cindex texinfo
36 @cindex latex
37 @cindex texinfo
38 @cindex texi
39 @cindex html
40 @cindex docbook
41 @cindex documents, adding music to
42 @cindex HTML, music in
43 @cindex Texinfo, music in
44 @cindex DocBook, music in
45 @cindex @LaTeX{}, music in
46
47 @menu
48 * An example of a musicological document::
49 * Integrating music and text::
50 * Music fragment options::
51 * Invoking lilypond-book::
52 * Filename extensions::
53 * Alternate methods of mixing text and music::
54 @end menu
55
56
57 @node An example of a musicological document
58 @section An example of a musicological document
59
60 @cindex musicology
61 Some texts contain music examples.  These texts are musicological
62 treatises, songbooks, or manuals like this.  Such texts can be made by
63 hand, simply by importing a PostScript figure into the word processor.
64 However, there is an automated procedure to reduce the amount of work
65 involved in HTML, @LaTeX{}, Texinfo and DocBook documents.
66
67 A script called @code{lilypond-book} will extract the music fragments,
68 format them, and put back the resulting notation.  Here we show a small
69 example for use with @LaTeX{}.  The example also contains explanatory
70 text, so we will not comment on it further.
71
72 @subheading Input
73
74 @quotation
75 @verbatim
76 \documentclass[a4paper]{article}
77
78 \begin{document}
79
80 Documents for \verb+lilypond-book+ may freely mix music and text.
81 For example,
82
83 \begin{lilypond}
84 \relative c' {
85   c2 g'2 \times 2/3 { f8 e d } c'2 g4
86 }
87 \end{lilypond}
88
89 Options are put in brackets.
90
91 \begin[fragment,quote,staffsize=26,verbatim]{lilypond}
92   c'4 f16
93 \end{lilypond}
94
95 Larger examples can be put into a separate file, and introduced with
96 \verb+\lilypondfile+.
97
98 \lilypondfile[quote,noindent]{screech-boink.ly}
99
100 (If needed, replace screech-boink.ly by any .ly file you put in the same
101 directory as this file.)
102
103 \end{document}
104 @end verbatim
105 @end quotation
106
107 @subheading Processing
108
109 Save the code above to a file called @file{lilybook.lytex}, then in a
110 terminal run
111
112 @c keep space after @version{} so TeX doesn't choke
113 @example
114 lilypond-book --output=out --pdf lilybook.lytex
115 @emph{lilypond-book (GNU LilyPond) @version{} }
116 @emph{Reading lilybook.lytex...}
117 @emph{..lots of stuff deleted..}
118 @emph{Compiling lilybook.tex...}
119 cd out
120 pdflatex lilybook
121 @emph{..lots of stuff deleted..}
122 xpdf lilybook
123 @emph{(replace @command{xpdf} by your favorite PDF viewer)}
124 @end example
125
126 Running @command{lilypond-book} and @command{latex} creates a lot of
127 temporary files, which would clutter up the working directory.  To
128 remedy this, use the @code{--output=@var{dir}} option.  It will create
129 the files in a separate subdirectory @file{dir}.
130
131 Finally the result of the @LaTeX{} example shown above.@footnote{This
132 tutorial is processed with Texinfo, so the example gives slightly
133 different results in layout.}  This finishes the tutorial section.
134
135 @page
136
137 @subheading Output
138
139 Documents for @command{lilypond-book} may freely mix music and text.
140 For example,
141
142 @lilypond
143 \relative c' {
144   c2 g'2 \times 2/3 { f8 e d } c'2 g4
145 }
146 @end lilypond
147
148 Options are put in brackets.
149
150 @lilypond[fragment,quote,staffsize=26,verbatim]
151 c'4 f16
152 @end lilypond
153
154 Larger examples can be put into a separate file, and introduced with
155 @code{\lilypondfile}.
156
157 @lilypondfile[quote,noindent]{screech-boink.ly}
158
159
160 @page
161
162 @node Integrating music and text
163 @section Integrating music and text
164
165 Here we explain how to integrate LilyPond with various output formats.
166
167 @menu
168 * LaTeX::
169 * Texinfo::
170 * HTML::
171 * DocBook::
172 @end menu
173
174 @node LaTeX
175 @subsection @LaTeX{}
176
177 @LaTeX{} is the de-facto standard for publishing layouts in the exact
178 sciences.  It is built on top of the @TeX{} typesetting engine,
179 providing the best typography available anywhere.
180
181 See
182 @uref{http://@/www@/.ctan@/.org/@/tex@/-archive/@/info/@/lshort/@/english/,
183 @emph{The Not So Short Introduction to @LaTeX{}}} for an overview on how
184 to use @LaTeX{}.
185
186 Music is entered using
187
188 @example
189 \begin[options,go,here]@{lilypond@}
190   YOUR LILYPOND CODE
191 \end@{lilypond@}
192 @end example
193
194 @noindent
195 or
196
197 @example
198 \lilypondfile[options,go,here]@{@var{filename}@}
199 @end example
200
201 @noindent
202 or
203
204 @example
205 \lilypond@{ YOUR LILYPOND CODE @}
206 @end example
207
208 Additionally, @code{\lilypondversion} displays the the current version
209 of lilypond.
210 Running @command{lilypond-book} yields a file that can be further
211 processed with @LaTeX{}. 
212
213 We show some examples here.  The @code{lilypond} environment
214
215 @example
216 \begin[quote,fragment,staffsize=26]@{lilypond@}
217   c' d' e' f' g'2 g'2
218 \end@{lilypond@}
219 @end example
220
221 @noindent
222 produces
223
224 @lilypond[quote,fragment,staffsize=26]
225 c' d' e' f' g'2 g'2
226 @end lilypond
227
228 The short version
229
230 @example
231 \lilypond[quote,fragment,staffsize=11]@{<c' e' g'>@}
232 @end example
233
234 @noindent
235 produces
236
237 @lilypond[quote,fragment,staffsize=11]{<c' e' g'>}
238
239 @noindent
240 Currently, you cannot include @code{@{} or @code{@}} within
241 @code{\lilypond@{@}}, so this command is only useful with the
242 @code{fragment} option.
243
244 The default line width of the music will be adjusted by examining the
245 commands in the document preamble, the part of the document before
246 @code{\begin@{document@}}.  The @command{lilypond-book} command sends
247 these to @LaTeX{} to find out how wide the text is.  The line width for
248 the music fragments is then adjusted to the text width.  Note that this
249 heuristic algorithm can fail easily; in such cases it is necessary to
250 use the @code{line-width} music fragment option.
251
252 @cindex titling and lilypond-book
253 @cindex \header in @LaTeX{} documents
254
255 Each snippet will call the following macros if they have been defined by
256 the user:
257
258 @itemize bullet
259 @item @code{\preLilyPondExample} called before the music,
260
261 @item @code{\postLilyPondExample} called after the music,
262
263 @item @code{\betweenLilyPondSystem[1]} is called between systems if
264 @code{lilypond-book} has split the snippet into several PostScript
265 files.  It must be defined as taking one parameter and will be
266 passed the number of files already included in this snippet.
267 The default is to simply insert a @code{\linebreak}.
268 @end itemize
269
270 @ignore
271 Broken stuff.  :(
272
273 @cindex Latex, feta symbols
274 @cindex fetachar
275
276 To include feta symbols (such as flat, segno, etc) in a LaTeX
277 document, use @code{\input@{titledefs@}}
278
279 @example
280 \documentclass[a4paper]@{article@}
281
282 \input@{titledefs@}
283
284 \begin@{document@}
285
286 \fetachar\fetasharp
287
288 \end@{document@}
289 @end example
290
291 The font symbol names are defined in the file feta20.tex; to find
292 the location of this file, use the command
293
294 @example
295 kpsewhich feta20.tex
296 @end example
297
298 @end ignore
299
300 @snippets
301
302 Sometimes it is useful to display music elements (such as ties and slurs)
303 as if they continued after the end of the fragment.  This can be done by
304 breaking the staff and suppressing inclusion of the rest of the LilyPond
305 output.
306
307 In @LaTeX{}, define @code{\betweenLilyPondSystem} in such a way that
308 inclusion of other systems is terminated once the required number of
309 systems are included.  Since @code{\betweenLilypondSystem} is first
310 called @emph{after} the first system, including only the first system
311 is trivial.
312
313 @example
314 \def\betweenLilyPondSystem#1@{\endinput@}
315
316 \begin[fragment]@{lilypond@}
317   c'1\( e'( c'~ \break c' d) e f\)
318 \end@{lilypond@}
319 @end example
320
321 If a greater number of systems is requested, a @TeX{} conditional must
322 be used before the @code{\endinput}.  In this example, replace @q{2} by
323 the number of systems you want in the output,
324
325 @example
326 \def\betweenLilyPondSystem#1@{
327     \ifnum##1<2\else\endinput\fi
328 @}
329 @end example
330
331 Remember that the definition of @code{\betweenLilyPondSystem} is
332 effective until @TeX{} quits the current group (such as the @LaTeX{}
333 environment) or is overridden by another definition (which is, in
334 most cases, for the rest of the document).  To reset your
335 definition, write
336
337 @example
338 \let\betweenLilyPondSystem\undefined
339 @end example
340
341 @noindent
342 in your @LaTeX{} source.
343
344 This may be simplified by defining a @TeX{} macro
345
346 @example
347 \def\onlyFirstNSystems#1@{
348     \def\betweenLilyPondSystem##1@{\ifnum##1<#1\else\endinput\fi@}
349 @}
350 @end example
351
352 @noindent
353 and then saying only how many systems you want before each fragment,
354
355 @example
356 \onlyFirstNSystems@{3@}
357 \begin@{lilypond@}...\end@{lilypond@}
358 \onlyFirstNSystems@{1@}
359 \begin@{lilypond@}...\end@{lilypond@}
360 @end example
361
362 @seealso
363 There are specific @command{lilypond-book} command line options and
364 other details to know when processing @LaTeX{} documents, see
365 @ref{Invoking lilypond-book}.
366
367
368 @node Texinfo
369 @subsection Texinfo
370
371 Texinfo is the standard format for documentation of the GNU project.  An
372 example of a Texinfo document is this manual.  The HTML, PDF, and Info
373 versions of the manual are made from the Texinfo document.
374
375 In the input file, music is specified with
376
377 @example
378 @@lilypond[options,go,here]
379   YOUR LILYPOND CODE
380 @@end lilypond
381 @end example
382
383 @noindent
384 or
385
386 @example
387 @@lilypond[options,go,here]@{ YOUR LILYPOND CODE @}
388 @end example
389
390 @noindent
391 or
392
393 @example
394 @@lilypondfile[options,go,here]@{@var{filename}@}
395 @end example
396
397 Additionally, @code{@@lilypondversion} displays the the current version
398 of lilypond.
399
400 When @command{lilypond-book} is run on it, this results in a Texinfo
401 file (with extension @file{.texi}) containing @code{@@image} tags for
402 HTML, Info and printed output.  @command{lilypond-book} generates images
403 of the music in EPS and PDF formats for use in the printed output, and
404 in PNG format for use in HTML and Info output.
405
406 We show two simple examples here.  A @code{lilypond} environment
407
408 @example
409 @@lilypond[fragment]
410 c' d' e' f' g'2 g'
411 @@end lilypond
412 @end example
413
414 @noindent
415 produces
416
417 @lilypond[fragment]
418 c' d' e' f' g'2 g'
419 @end lilypond
420
421 The short version
422
423 @example
424 @@lilypond[fragment,staffsize=11]@{<c' e' g'>@}
425 @end example
426
427 @noindent
428 produces
429
430 @lilypond[fragment,staffsize=11]{<c' e' g'>}
431
432 Contrary to @LaTeX{}, @code{@@lilypond@{...@}} does not generate an
433 in-line image.  It always gets a paragraph of its own.
434
435
436 @node HTML
437 @subsection HTML
438
439 Music is entered using
440
441 @example
442 <lilypond fragment relative=2>
443 \key c \minor c4 es g2
444 </lilypond>
445 @end example
446 @noindent
447 @command{lilypond-book} then produces an HTML file with appropriate image
448 tags for the music fragments:
449
450 @lilypond[fragment,relative=2]
451 \key c \minor c4 es g2
452 @end lilypond
453
454 For inline pictures, use @code{<lilypond ... />}, where the options
455 are separated by a colon from the music, for example
456
457 @example
458 Some music in <lilypond relative=2: a b c/> a line of text.
459 @end example
460
461
462 To include separate files, say
463
464 @example
465 <lilypondfile @var{option1} @var{option2} ...>@var{filename}</lilypondfile>
466 @end example
467
468 Additionally, @code{<lilypondversion/>} displays the the current version
469 of lilypond.
470
471
472 @cindex titling in HTML
473 @cindex preview image
474 @cindex thumbnail
475
476 @node DocBook
477 @subsection DocBook
478
479 For inserting LilyPond snippets it is good to keep the conformity of our
480 DocBook document, thus allowing us to use DocBook editors, validation
481 etc. So we don't use custom tags, only specify a convention based on the
482 standard DocBook elements.
483
484 @subheading Common conventions
485
486 For inserting all type of snippets we use the @code{mediaobject} and
487 @code{inlinemediaobject} element, so our snippets can be formatted
488 inline or not inline.  The snippet formatting options are always
489 provided in the @code{role} property of the innermost element (see in
490 next sections).  Tags are chosen to allow DocBook editors format the
491 content gracefully.  The DocBook files to be processed with
492 @command{lilypond-book} should have the extension @file{.lyxml}.
493
494 @subheading Including a LilyPond file
495
496 This is the most simple case.  We must use the @file{.ly} extension for
497 the included file, and insert it as a standard @code{imageobject}, with
498 the following structure:
499
500 @example
501 <mediaobject>
502   <imageobject>
503     <imagedata fileref="music1.ly" role="printfilename" />
504   </imageobject>
505 </mediaobject>
506 @end example
507
508 Note that you can use @code{mediaobject} or @code{inlinemediaobject}
509 as the outermost element as you wish.
510
511 @subheading Including LilyPond code
512
513 Including LilyPond code is possible by using a @code{programlisting},
514 where the language is set to @code{lilypond} with the following
515 structure:
516
517 @example
518 <inlinemediaobject>
519   <textobject>
520     <programlisting language="lilypond" role="fragment verbatim staffsize=16 ragged-right relative=2">
521 \context Staff \with @{
522   \remove Time_signature_engraver
523   \remove Clef_engraver@}
524   @{ c4( fis) @}
525     </programlisting>
526   </textobject>
527 </inlinemediaobject>
528 @end example
529
530 As you can see, the outermost element is a @code{mediaobject} or
531 @code{inlinemediaobject}, and there is a @code{textobject} containing
532 the @code{programlisting} inside.
533
534 @subheading Processing the DocBook document
535
536 Running @command{lilypond-book} on our @file{.lyxml} file will create a
537 valid DocBook document to be further processed with @file{.xml}
538 extension.  If you use
539 @uref{http://@/dblatex@/.sourceforge@/.net@/,dblatex}, it will create a
540 PDF file from this document automatically.  For HTML (HTML Help,
541 JavaHelp etc.) generation you can use the official DocBook XSL
542 stylesheets, however, it is possible that you have to make some
543 customization for it.
544
545
546 @node Music fragment options
547 @section Music fragment options
548
549 In the following, a @q{LilyPond command} refers to any command described
550 in the previous sections which is handled by @command{lilypond-book} to
551 produce a music snippet.  For simplicity, LilyPond commands are only
552 shown in @LaTeX{} syntax.
553
554 Note that the option string is parsed from left to right; if an option
555 occurs multiple times, the last one is taken.
556
557 The following options are available for LilyPond commands:
558
559 @table @code
560 @item staffsize=@var{ht}
561 Set staff size to @var{ht}, which is measured in points.
562
563 @item ragged-right
564 Produce ragged-right lines with natural spacing, i.e.,
565 @code{ragged-right = ##t} is added to the LilyPond snippet.  This is the
566 default for the @code{\lilypond@{@}} command if no @code{line-width}
567 option is present.  It is also the default for the @code{lilypond}
568 environment if the @code{fragment} option is set, and no line width is
569 explicitly specified.
570
571 @item noragged-right
572 For single-line snippets, allow the staff length to be stretched to
573 equal that of the line width, i.e., @code{ragged-right = ##f} is
574 added to the LilyPond snippet.
575
576 @c does this option still exist in lilypond? -jm
577 @item packed
578 Produce lines with packed spacing, i.e., @code{packed = ##t} is added
579 to the LilyPond snippet.
580
581 @item line-width
582 @itemx line-width=@var{size}\@var{unit}
583 Set line width to @var{size}, using @var{unit} as units.  @var{unit} is
584 one of the following strings: @code{cm}, @code{mm}, @code{in}, or
585 @code{pt}.  This option affects LilyPond output (this is, the staff
586 length of the music snippet), not the text layout.
587
588 If used without an argument, set line width to a default value (as
589 computed with a heuristic algorithm).
590
591 If no @code{line-width} option is given, @command{lilypond-book} tries to
592 guess a default for @code{lilypond} environments which don't use the
593 @code{ragged-right} option.
594
595 @item notime
596 Do not print the time signature, and turns off the timing (time signature,
597 bar lines) in the score.
598
599 @item fragment
600 Make @command{lilypond-book} add some boilerplate code so that you can
601 simply enter, say,
602
603 @example
604 c'4
605 @end example
606
607 @noindent
608 without @code{\layout}, @code{\score}, etc.
609
610 @item nofragment
611 Do not add additional code to complete LilyPond code in music snippets.
612 Since this is the default, @code{nofragment} is redundant normally.
613
614 @item indent=@var{size}\@var{unit}
615 Set indentation of the first music system to @var{size}, using
616 @var{unit} as units. @var{unit} is one of the following strings:
617 @code{cm}, @code{mm}, @code{in}, or @code{pt}.  This option affects
618 LilyPond, not the text layout.
619
620 @item noindent
621 Set indentation of the first music system to zero.  This option affects
622 LilyPond, not the text layout.  Since no indentation is the default,
623 @code{noindent} is redundant normally.
624
625 @item quote
626 Reduce line length of a music snippet by @math{2*0.4}@dmn{in} and put
627 the output into a quotation block.  The value @q{0.4@dmn{in}} can be
628 controlled with the @code{exampleindent} option.
629
630 @item exampleindent
631 Set the amount by which the @code{quote} option indents a music snippet.
632
633 @item relative
634 @itemx relative=@var{n}
635 Use relative octave mode.  By default, notes are specified relative to
636 middle@tie{}C.  The optional integer argument specifies the octave of
637 the starting note, where the default @code{1} is middle C.
638 @code{relative} option only works when @code{fragment} option is set,
639 so @code{fragment} is automatically implied by @code{relative},
640 regardless of the presence of any @code{(no)fragment} option in the
641 source.
642 @end table
643
644 LilyPond also uses @command{lilypond-book} to produce its own
645 documentation.  To do that, some more obscure music fragment options are
646 available.
647
648 @table @code
649 @item verbatim
650 The argument of a LilyPond command is copied to the output file and
651 enclosed in a verbatim block, followed by any text given with the
652 @code{intertext} option (not implemented yet); then the actual music is
653 displayed.  This option does not work well with @code{\lilypond@{@}} if
654 it is part of a paragraph.
655
656 If @code{verbatim} is used in a @code{lilypondfile} command, it is
657 possible to enclose verbatim only a part of the source file.  If the
658 source file contain a comment containing @samp{begin verbatim} (without
659 quotes), quoting the source in the verbatim block will start after the
660 last occurrence of such a comment; similarly, quoting the source verbatim
661 will stop just before the first occurrence of a comment containing
662 @samp{end verbatim}, it there is any.  In the following source file
663 example, the music will be interpreted in relative mode, but the
664 verbatim quote will not show the @code{relative} block, i.e.
665
666 @example
667 \relative c' @{ % begin verbatim
668   c4 e2 g4
669   f2 e % end verbatim
670 @}
671 @end example
672
673 @noindent
674 will be printed with a verbatim block like
675
676 @example
677   c4 e2 g4
678   f2 e
679 @end example
680
681 @item addversion
682 (Only for Texinfo output.)  Prepend line @code{\version
683 @@w@{"@@version@{@}"@}} to @code{verbatim} output.
684
685 @item texidoc
686 (Only for Texinfo output.)  If @command{lilypond} is called with the
687 @option{--header=@/texidoc} option, and the file to be processed is
688 called @file{foo@/.ly}, it creates a file @file{foo@/.texidoc} if there
689 is a @code{texidoc} field in the @code{\header}.  The @code{texidoc}
690 option makes @command{lilypond-book} include such files, adding its
691 contents as a documentation block right before the music snippet.
692
693 Assuming the file @file{foo@/.ly} contains
694
695 @example
696 \header @{
697   texidoc = "This file demonstrates a single note."
698 @}
699 @{ c'4 @}
700 @end example
701
702 @noindent
703 and we have this in our Texinfo document @file{test.texinfo}
704
705 @example
706 @@lilypondfile[texidoc]@{foo.ly@}
707 @end example
708
709 @noindent
710 the following command line gives the expected result
711
712 @example
713 lilypond-book --process="lilypond --format=tex --tex \
714               --header=texidoc test.texinfo
715 @end example
716
717 Most LilyPond test documents (in the @file{input} directory of the
718 distribution) are small @file{.ly} files which look exactly like this.
719
720 For localization purpose, if the Texinfo document contains
721 @code{@@documentlanguage @var{LANG}} and @file{foo@/.ly} header
722 contains a @code{texidoc@var{LANG}} field, and if @command{lilypond}
723 is called with @option{--header=@/texidoc@var{LANG}}, then
724 @file{foo@/.texidoc@var{LANG}} will be included instead of
725 @file{foo@/.texidoc}.
726
727 @item lilyquote
728 (Only for Texinfo output.)  This option is similar to quote, but only
729 the music snippet (and the optional verbatim block implied by
730 @code{verbatim} option) is put into a quotation block.  This option is
731 useful if you want to @code{quote} the music snippet but not the
732 @code{texidoc} documentation block.
733
734 @item doctitle
735 (Only for Texinfo output.) This option works similarly to
736 @code{texidoc} option: if @command{lilypond} is called with the
737 @option{--header=@/doctitle} option, and the file to be processed is
738 called @file{foo@/.ly} and contains a @code{doctitle} field in the
739 @code{\header}, it creates a file @file{foo@/.doctitle}.  When
740 @code{doctitle} option is used, the contents of @file{foo@/.doctitle},
741 which should be a single line of @var{text}, is inserted in the
742 Texinfo document as @code{@@lydoctitle @var{text}}.
743 @code{@@lydoctitle} should be a macro defined in the Texinfo document.
744 The same remark about @code{texidoc} processing with localized
745 languages also applies to @code{doctitle}.
746
747 @item printfilename
748 If a LilyPond input file is included with @code{\lilypondfile}, print
749 the file name right before the music snippet.  For HTML output, this
750 is a link.  Only the base name of the file is printed, i.e. the
751 directory part of the file path is stripped.
752
753 @item fontload
754 This option includes fonts in all of the generated EPS-files for this
755 snippet.  This should be used if the snippet uses any font that @LaTeX{}
756 cannot find on its own.
757
758 @end table
759
760
761 @node Invoking lilypond-book
762 @section Invoking @command{lilypond-book}
763
764 @command{lilypond-book} produces a file with one of the following
765 extensions: @file{.tex}, @file{.texi}, @file{.html} or @file{.xml},
766 depending on the output format.  All of @file{.tex}, @file{.texi} and
767 @file{.xml} files need further processing.
768
769 @subheading Format-specific instructions
770
771 @subsubheading @LaTeX{}
772
773 There are two ways of processing your @LaTeX{} document for printing or
774 publishing: getting a PDF file directly with PDF@LaTeX{}, or getting a
775 PostScript file with @LaTeX{} via a DVI to PostScript translator like
776 @command{dvips}.  The first way is simpler and recommended@footnote{Note
777 that PDF@LaTeX{} and @LaTeX{} may not be both usable to compile any
778 @LaTeX{} document, that is why we explain the two ways.}, and whichever
779 way you use, you can easily convert between PostScript and PDF with
780 tools, like @command{ps2pdf} and @command{pdf2ps} included in
781 Ghostscript package.
782
783 To produce a PDF file through PDF@LaTeX{}, use
784
785 @example
786 lilypond-book --pdf yourfile.pdftex
787 pdflatex yourfile.tex
788 @end example
789
790 @cindex outline fonts
791 @cindex type1 fonts
792 @cindex dvips
793 @cindex invoking dvips
794 To produce PDF output via @LaTeX{}/@command{dvips}/@command{ps2pdf}, you
795 should do
796
797 @example
798 lilypond-book yourfile.lytex
799 latex yourfile.tex
800 dvips -Ppdf yourfile.dvi
801 ps2pdf yourfile.ps
802 @end example
803
804 @noindent
805 The @file{.dvi} file created by this process will not contain
806  note heads.  This is normal; if you follow the instructions, they
807 will be included in the @file{.ps} and @file{.pdf} files.
808
809 Running @command{dvips} may produce some warnings about fonts; these
810 are harmless and may be ignored.  If you are running @command{latex} in
811 twocolumn mode, remember to add @code{-t landscape} to the
812 @command{dvips} options.
813
814 @subsubheading Texinfo
815
816 To produce a Texinfo document (in any output format), follow the normal
817 procedures for Texinfo; this is, either call @command{texi2pdf} or
818 @command{texi2dvi} or @command{makeinfo}, depending on the output format
819 you want to create.
820 @ifinfo
821 @xref{Format with texi2dvi, , , texinfo, GNU Texinfo}, and @ref{Creating
822 an Info File, , , texinfo, GNU Texinfo}.
823 @end ifinfo
824 @ifnotinfo
825 See the documentation of Texinfo for further details.
826 @end ifnotinfo
827
828
829 @subheading Command line options
830
831 @command{lilypond-book} accepts the following command line options:
832
833 @table @code
834 @item -f @var{format}
835 @itemx --format=@var{format}
836 Specify the document type to process: @code{html}, @code{latex},
837 @code{texi} (the default) or @code{docbook}.  If this option is missing,
838 @command{lilypond-book} tries to detect the format automatically, see
839 @ref{Filename extensions}. Currently, @code{texi} is the same as
840 @code{texi-html}.
841
842 @c This complicated detail is not implemented, comment it out -jm
843 @ignore
844 The @code{texi} document type produces a Texinfo file with music
845 fragments in the printed output only.  For getting images in the HTML
846 version, the format @code{texi-html} must be used instead.
847 @end ignore
848
849 @item -F @var{filter}
850 @itemx --filter=@var{filter}
851 Pipe snippets through @var{filter}.  @code{lilypond-book} will
852 not --filter and --process at the same time.  For example,
853
854 @example
855 lilypond-book --filter='convert-ly --from=2.0.0 -' my-book.tely
856 @end example
857
858 @item -h
859 @itemx --help
860 Print a short help message.
861
862 @item -I @var{dir}
863 @itemx --include=@var{dir}
864 Add @var{dir} to the include path.  @command{lilypond-book} also looks
865 for already compiled snippets in the include path, and does not write
866 them back to the output directory, so in some cases it is necessary to
867 invoke further processing commands such as @command{makeinfo} or
868 @command{latex} with the same @code{-I @var{dir}} options.
869
870 @item -o @var{dir}
871 @itemx --output=@var{dir}
872 Place generated files in directory @var{dir}.  Running
873 @command{lilypond-book} generates lots of small files that LilyPond will
874 process.  To avoid all that garbage in the source directory, use the
875 @option{--output} command line option, and change to that directory
876 before running @command{latex} or @command{makeinfo}.
877
878 @example
879 lilypond-book --output=out yourfile.lytex
880 cd out
881 ...
882 @end example
883
884 @itemx --skip-lily-check
885 Do not fail if no lilypond output is found.  It is used for LilyPond
886 Info documentation without images.
887
888 @itemx --skip-png-check
889 Do not fail if no PNG images are found for EPS files.  It is used for
890 LilyPond Info documentation without images.
891
892 @itemx --lily-output-dir=@var{dir}
893 Write lily-XXX files to directory @var{dir}, link into @code{--output}
894 directory.  Use this option to save building time for documents in
895 different directories which share a lot of identical snippets.
896
897 @itemx --info-images-dir=@var{dir}
898 Format Texinfo output so that Info will look for images of music in
899 @var{dir}.
900
901 @itemx --latex-program=@var{prog}
902 Run executable @command{prog} instead of @command{latex}.  This is
903 useful if your document is processed with @command{xelatex}, for
904 example.
905
906 @itemx --left-padding=@var{amount}
907 Pad EPS boxes by this much. @var{amount} is measured in millimeters,
908 and is 3.0 by default.  This option should be used if the lines of
909 music stick out of the right margin.
910
911 The width of a tightly clipped system can vary, due to notation
912 elements that stick into the left margin, such as bar numbers and
913 instrument names.  This option will shorten each line and move each
914 line to the right by the same amount.
915
916
917 @item -P @var{command}
918 @itemx --process=@var{command}
919 Process LilyPond snippets using @var{command}.  The default command is
920 @code{lilypond}.  @code{lilypond-book} will not @code{--filter} and
921 @code{--process} at the same time.
922
923 @item --pdf
924 Create PDF files for use with PDF@LaTeX{}.
925
926 @item -V
927 @itemx --verbose
928 Be verbose.
929
930 @item -v
931 @itemx --version
932 Print version information.
933 @end table
934
935 @knownissues
936
937 The Texinfo command @code{@@pagesizes} is not interpreted.  Similarly,
938 @LaTeX{} commands that change margins and line widths after the preamble
939 are ignored.
940
941 Only the first @code{\score} of a LilyPond block is processed.
942
943
944 @node Filename extensions
945 @section Filename extensions
946
947 You can use any filename extension for the input file, but if you do not
948 use the recommended extension for a particular format you may need to
949 manually specify the output format; for details, see @ref{Invoking
950 lilypond-book}.  Otherwise, @command{lilypond-book} automatically
951 selects the output format based on the input filename's extension.
952
953 @quotation
954 @multitable @columnfractions .2 .5
955 @item @strong{extension} @tab @strong{output format}
956 @item
957 @item @file{.html} @tab HTML
958 @item @file{.itely} @tab Texinfo
959 @item @file{.latex} @tab @LaTeX{}
960 @item @file{.lytex} @tab @LaTeX{}
961 @item @file{.lyxml} @tab DocBook
962 @item @file{.tely} @tab Texinfo
963 @item @file{.tex} @tab @LaTeX{}
964 @item @file{.texi} @tab Texinfo
965 @item @file{.texinfo} @tab Texinfo
966 @item @file{.xml} @tab HTML
967 @end multitable
968 @end quotation
969
970 If you use the same filename extension for the input file than the
971 extension @command{lilypond-book} uses for the output file, and if the
972 input file is in the same directory as @command{lilypond-book} working
973 directory, you must use @code{--output} option to make
974 @command{lilypond-book} running, otherwise the will exit with an error
975 message like @qq{Output would overwrite input file}.
976
977
978 @node Alternate methods of mixing text and music
979 @section Alternative methods of mixing text and music
980
981 This section shows methods to integrate text and music, different than
982 the automated method with @command{lilypond-book}.
983
984 @menu
985 * Many quotes from a large score::
986 * Inserting LilyPond output into OpenOffice.org::
987 * Inserting LilyPond output into other programs::
988 @end menu
989
990 @node Many quotes from a large score
991 @unnumberedsubsec Many quotes from a large score
992
993 If you need to quote many fragments from a large score, you can also use
994 the clip systems feature, see @ruser{Extracting fragments of music}.
995
996
997 @node Inserting LilyPond output into OpenOffice.org
998 @unnumberedsubsec Inserting LilyPond output into OpenOffice.org
999
1000 @cindex OpenOffice.org
1001
1002 LilyPond notation can be added to OpenOffice.org with
1003 @uref{http://@/ooolilypond@/.sourceforge@/.net@/,OOoLilyPond}.
1004
1005
1006 @node Inserting LilyPond output into other programs
1007 @unnumberedsubsec Inserting LilyPond output into other programs
1008
1009 To insert LilyPond output in other programs, use @code{lilypond}
1010 instead of @code{lilypond-book}.  Each example must be created
1011 individually and added to the document; consult the documentation for
1012 that program.  Most programs will be able to insert LilyPond output in
1013 @file{PNG}, @file{EPS}, or @file{PDF} formats.
1014
1015 To reduce the white space around your LilyPond score, use
1016 the following options
1017
1018 @example
1019 \paper@{
1020   indent=0\mm
1021   line-width=120\mm
1022   oddFooterMarkup=##f
1023   oddHeaderMarkup=##f
1024   bookTitleMarkup = ##f
1025   scoreTitleMarkup = ##f
1026 @}
1027
1028 @{ c1 @}
1029 @end example
1030
1031 To produce a useful @file{EPS} file, use
1032
1033 @example
1034 lilypond -dbackend=eps -dno-gs-load-fonts -dinclude-eps-fonts   myfile.ly
1035
1036 @file{PNG}:
1037 lilypond -dbackend=eps -dno-gs-load-fonts -dinclude-eps-fonts --png myfile.ly
1038 @end example
1039