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