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