]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/hu/usage/lilypond-book.itely
Docs: Get rid of lilyquote snippet option, replaced by ordinary quote
[lilypond.git] / Documentation / hu / usage / lilypond-book.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2
3 @ignore
4     Translation of GIT committish: f77212d801fa4603bf596a19cecf5a068f1d9d85
5
6     When revising a translation, copy the HEAD committish of the
7     version that you are working on.  For details, see the Contributors'
8     Guide, node Updating translation committishes..
9 @end ignore
10
11 @c \version "2.13.36"
12
13 @c Note: keep this node named so that `info lilypond-book' brings you here.
14 @node lilypond-book
15 @chapter A @command{lilypond-book} használata
16 @translationof lilypond-book
17
18 Amennyiben egy dokumentumba kottapéldákat szeretnénk beszúrni, megtehetjük,
19 hogy azok képeit egyesével létrehozzuk a LilyPond segítségével PostScript
20 vagy PNG formátumban, és mint bármilyen más képeket, beillesztjük azokat egy
21 @LaTeX{} vagy HTML dokumentumba.
22
23 A @command{lilypond-book} ennek a folyamatnak az automatizálására szolgál:
24 ez a program kiszedi a LilyPond kódrészleteket egy dokumentumból, lefordítja
25 őket a @command{lilypond} segítségével, és az így kapott képeket beilleszti
26 az eredeti kódrészletek helyére. A kottakép méretei igazodnak a dokumentum
27 elrendezéséhez.
28
29 A @command{lilypond-book} egy különálló parancssori program; a parancssoros
30 programok futtatásának módját a @ref{Parancssori használat} írja le bővebben.
31
32 A @command{lilypond-book} jelenleg a @LaTeX{}, HTML, Texinfo és DocBook
33 formátumokat támogatja.
34
35 @cindex texinfo
36 @cindex latex
37 @cindex texinfo
38 @cindex texi
39 @cindex html
40 @cindex docbook
41 @cindex dokumentumok, kottapéldák
42 @cindex HTML, kottapéldák
43 @cindex Texinfo, kottapéldák
44 @cindex DocBook, kottapéldák
45 @cindex @LaTeX{}, kottapéldák
46
47 @menu
48 * Egy kottapéldákat tartalmazó dokumentum::
49 * Zene és szöveg integrációja::
50 * Kottapéldák paraméterei::
51 * A lilypond-book futtatása::
52 * Fájlkiterjesztések::
53 * lilypond-book sablonok::
54 * Közös tartalomjegyzék::
55 * További módszerek zene és szöveg kombinálására::
56 @end menu
57
58
59 @node Egy kottapéldákat tartalmazó dokumentum
60 @section Egy kottapéldákat tartalmazó dokumentum
61 @translationof An example of a musicological document
62
63 @cindex zenetudomány
64 Bizonyos dokumentumok kottapéldákat tartalmaznak. Ezek között vannak
65 zenetudományi értekezések, énekeskönyvek, vagy ehhez hasonló kézikönyvek.
66 Ezeket úgy is el lehet készíteni, hogy a szövegbe beillesztjük a kottaábrákat.
67 Azonban ahhoz, hogy ne kelljen minden egyes kottarészlet szedését külön
68 elvégezni, a HTML, @LaTeX{}, Texinfo és DocBook formátumú dokumentumok esetén
69 mód nyílik ennek automatizálására.
70
71 Egy @code{lilypond-book} nevű parancsfájl a LilyPond nyelvén írt
72 kódrészleteket szépen formázott kottapéldákká alakítja át. Íme egy rövid,
73 magyarázatokkal ellátott @LaTeX{} példa.
74
75 @subheading Bemenet
76
77 @quotation
78 @verbatim
79 \documentclass[a4paper]{article}
80
81 \begin{document}
82
83 A \verb+lilypond-book+ segítségével feldolgozott dokumentumok
84 kottapéldákat tartalmazhatnak. Például:
85
86 \begin{lilypond}
87 \relative c' {
88   c2 e2 \times 2/3 { f8 a b } a2 e4
89 }
90 \end{lilypond}
91
92 A beállításokat szögletes zárójelbe kell tenni:
93
94 \begin{lilypond}[fragment,quote,staffsize=26,verbatim]
95   c'4 f16
96 \end{lilypond}
97
98 A nagyobb kottapéldákat ki lehet emelni külön fájlba, majd beilleszteni
99 őket a \verb+\lilypondfile+ paranccsal:
100
101 \lilypondfile[quote,noindent]{screech-boink.ly}
102
103 \end{document}
104 @end verbatim
105 @end quotation
106
107 @subheading Feldolgozás
108
109 A fenti dokumentumot egy @file{lilybook.lytex} nevű fájlba mentve futtassuk le
110 a következő parancsokat:
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{...}
118 @emph{Compiling lilybook.tex...}
119 cd out
120 pdflatex lilybook
121 @emph{...}
122 xpdf lilybook
123 @emph{(az @command{xpdf} helyére értelemszerűen tetszőleges PDF-nézegető
124 kerülhet)}
125 @end example
126
127 A @command{lilypond-book} és a @command{latex} rengeteg ideiglenes fájlt
128 hoznak létre. Annak érdekében, hogy ezek külön alkönyvtárba kerüljenek, a
129 @code{--output=@var{alkönyvtár}} opciót kell megadni.
130
131 Lent látható a fenti @LaTeX{} példa kimenete.@footnote{Ezt a dokumentumot a
132 Texinfo generálta, így apró eltérések lehetnek.} Ezzel elsajátítottuk a
133 lilypond-book használatának alapjait.
134
135 @page
136
137 @subheading Kimenet
138
139 A @command{lilypond-book} segítségével feldolgozott dokumentumok
140 kottapéldákat tartalmazhatnak. Például:
141
142 @lilypond
143 \relative c' {
144   c2 e2 \times 2/3 { f8 a b } a2 e4
145 }
146 @end lilypond
147
148 A beállításokat szögletes zárójelbe kell tenni:
149
150 @lilypond[fragment,quote,staffsize=26,verbatim]
151 c'4 f16
152 @end lilypond
153
154 A nagyobb kottapéldákat ki lehet emelni külön fájlba, majd beilleszteni
155 őket a @code{\lilypondfile} paranccsal:
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@{lilypond@}[options,go,here]
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[options,go,here]@{ YOUR LILYPOND CODE @}
206 @end example
207
208 Additionally, @code{\lilypondversion} displays 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@{lilypond@}[quote,fragment,staffsize=26]
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@{lilypond@}[fragment]
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\expandafter\endinput\fi
328 @}
329 @end example
330
331 @noindent
332 (Since @code{\endinput} immediately stops the processing of the current
333 input file we need @code{\expandafter} to delay the call of @code{\endinput}
334 after executing @code{\fi} so that the @code{\if}-@code{\fi} clause is
335 balanced.)
336
337 Remember that the definition of @code{\betweenLilyPondSystem} is
338 effective until @TeX{} quits the current group (such as the @LaTeX{}
339 environment) or is overridden by another definition (which is, in
340 most cases, for the rest of the document).  To reset your
341 definition, write
342
343 @example
344 \let\betweenLilyPondSystem\undefined
345 @end example
346
347 @noindent
348 in your @LaTeX{} source.
349
350 This may be simplified by defining a @TeX{} macro
351
352 @example
353 \def\onlyFirstNSystems#1@{
354     \def\betweenLilyPondSystem##1@{%
355       \ifnum##1<#1\else\expandafter\endinput\fi@}
356 @}
357 @end example
358
359 @noindent
360 and then saying only how many systems you want before each fragment,
361
362 @example
363 \onlyFirstNSystems@{3@}
364 \begin@{lilypond@}...\end@{lilypond@}
365 \onlyFirstNSystems@{1@}
366 \begin@{lilypond@}...\end@{lilypond@}
367 @end example
368
369
370 @seealso
371 There are specific @command{lilypond-book} command line options and
372 other details to know when processing @LaTeX{} documents, see
373 @ref{Invoking lilypond-book}.
374
375
376 @node Texinfo
377 @subsection Texinfo
378
379 Texinfo is the standard format for documentation of the GNU project.  An
380 example of a Texinfo document is this manual.  The HTML, PDF, and Info
381 versions of the manual are made from the Texinfo document.
382
383 In the input file, music is specified with
384
385 @example
386 @@lilypond[options,go,here]
387   YOUR LILYPOND CODE
388 @@end lilypond
389 @end example
390
391 @noindent
392 or
393
394 @example
395 @@lilypond[options,go,here]@{ YOUR LILYPOND CODE @}
396 @end example
397
398 @noindent
399 or
400
401 @example
402 @@lilypondfile[options,go,here]@{@var{filename}@}
403 @end example
404
405 Additionally, @code{@@lilypondversion} displays the current version
406 of lilypond.
407
408 When @command{lilypond-book} is run on it, this results in a Texinfo
409 file (with extension @file{.texi}) containing @code{@@image} tags for
410 HTML, Info and printed output.  @command{lilypond-book} generates images
411 of the music in EPS and PDF formats for use in the printed output, and
412 in PNG format for use in HTML and Info output.
413
414 We show two simple examples here.  A @code{lilypond} environment
415
416 @example
417 @@lilypond[fragment]
418 c' d' e' f' g'2 g'
419 @@end lilypond
420 @end example
421
422 @noindent
423 produces
424
425 @lilypond[fragment]
426 c' d' e' f' g'2 g'
427 @end lilypond
428
429 The short version
430
431 @example
432 @@lilypond[fragment,staffsize=11]@{<c' e' g'>@}
433 @end example
434
435 @noindent
436 produces
437
438 @lilypond[fragment,staffsize=11]{<c' e' g'>}
439
440 Contrary to @LaTeX{}, @code{@@lilypond@{...@}} does not generate an
441 in-line image.  It always gets a paragraph of its own.
442
443
444 @node HTML
445 @subsection HTML
446
447 Music is entered using
448
449 @example
450 <lilypond fragment relative=2>
451 \key c \minor c4 es g2
452 </lilypond>
453 @end example
454
455 @noindent
456 @command{lilypond-book} then produces an HTML file with appropriate image
457 tags for the music fragments:
458
459 @lilypond[fragment,relative=2]
460 \key c \minor c4 es g2
461 @end lilypond
462
463 For inline pictures, use @code{<lilypond ... />}, where the options
464 are separated by a colon from the music, for example
465
466 @example
467 Some music in <lilypond relative=2: a b c/> a line of text.
468 @end example
469
470 To include separate files, say
471
472 @example
473 <lilypondfile @var{option1} @var{option2} ...>@var{filename}</lilypondfile>
474 @end example
475
476 For a list of options to use with the @code{lilypond} or
477 @code{lilypondfile} tags, see @ref{Music fragment options}.
478
479 Additionally, @code{<lilypondversion/>} displays the current version
480 of lilypond.
481
482
483 @cindex titling in HTML
484 @cindex preview image
485 @cindex thumbnail
486
487 @node DocBook
488 @subsection DocBook
489
490 For inserting LilyPond snippets it is good to keep the conformity of our
491 DocBook document, thus allowing us to use DocBook editors, validation
492 etc.  So we don't use custom tags, only specify a convention based on the
493 standard DocBook elements.
494
495 @subheading Common conventions
496
497 For inserting all type of snippets we use the @code{mediaobject} and
498 @code{inlinemediaobject} element, so our snippets can be formatted
499 inline or not inline.  The snippet formatting options are always
500 provided in the @code{role} property of the innermost element (see in
501 next sections).  Tags are chosen to allow DocBook editors format the
502 content gracefully.  The DocBook files to be processed with
503 @command{lilypond-book} should have the extension @file{.lyxml}.
504
505 @subheading Including a LilyPond file
506
507 This is the most simple case.  We must use the @file{.ly} extension for
508 the included file, and insert it as a standard @code{imageobject}, with
509 the following structure:
510
511 @example
512 <mediaobject>
513   <imageobject>
514     <imagedata fileref="music1.ly" role="printfilename" />
515   </imageobject>
516 </mediaobject>
517 @end example
518
519 Note that you can use @code{mediaobject} or @code{inlinemediaobject}
520 as the outermost element as you wish.
521
522 @subheading Including LilyPond code
523
524 Including LilyPond code is possible by using a @code{programlisting},
525 where the language is set to @code{lilypond} with the following
526 structure:
527
528 @example
529 <inlinemediaobject>
530   <textobject>
531     <programlisting language="lilypond" role="fragment verbatim staffsize=16 ragged-right relative=2">
532 \context Staff \with @{
533   \remove Time_signature_engraver
534   \remove Clef_engraver@}
535   @{ c4( fis) @}
536     </programlisting>
537   </textobject>
538 </inlinemediaobject>
539 @end example
540
541 As you can see, the outermost element is a @code{mediaobject} or
542 @code{inlinemediaobject}, and there is a @code{textobject} containing
543 the @code{programlisting} inside.
544
545 @subheading Processing the DocBook document
546
547 Running @command{lilypond-book} on our @file{.lyxml} file will create a
548 valid DocBook document to be further processed with @file{.xml}
549 extension.  If you use
550 @uref{http://@/dblatex@/.sourceforge@/.net@/,dblatex}, it will create a
551 PDF file from this document automatically.  For HTML (HTML Help,
552 JavaHelp etc.) generation you can use the official DocBook XSL
553 stylesheets, however, it is possible that you have to make some
554 customization for it.
555
556
557 @node Music fragment options
558 @section Music fragment options
559
560 In the following, a @q{LilyPond command} refers to any command described
561 in the previous sections which is handled by @command{lilypond-book} to
562 produce a music snippet.  For simplicity, LilyPond commands are only
563 shown in @LaTeX{} syntax.
564
565 Note that the option string is parsed from left to right; if an option
566 occurs multiple times, the last one is taken.
567
568 The following options are available for LilyPond commands:
569
570 @table @code
571 @item staffsize=@var{ht}
572 Set staff size to @var{ht}, which is measured in points.
573
574 @item ragged-right
575 Produce ragged-right lines with natural spacing, i.e.,
576 @code{ragged-right = ##t} is added to the LilyPond snippet.  This is the
577 default for the @code{\lilypond@{@}} command if no @code{line-width}
578 option is present.  It is also the default for the @code{lilypond}
579 environment if the @code{fragment} option is set, and no line width is
580 explicitly specified.
581
582 @item noragged-right
583 For single-line snippets, allow the staff length to be stretched to
584 equal that of the line width, i.e., @code{ragged-right = ##f} is
585 added to the LilyPond snippet.
586
587 @item line-width
588 @itemx line-width=@var{size}\@var{unit}
589 Set line width to @var{size}, using @var{unit} as units.  @var{unit} is
590 one of the following strings: @code{cm}, @code{mm}, @code{in}, or
591 @code{pt}.  This option affects LilyPond output (this is, the staff
592 length of the music snippet), not the text layout.
593
594 If used without an argument, set line width to a default value (as
595 computed with a heuristic algorithm).
596
597 If no @code{line-width} option is given, @command{lilypond-book} tries to
598 guess a default for @code{lilypond} environments which don't use the
599 @code{ragged-right} option.
600
601 @item notime
602 Do not print the time signature, and turns off the timing (time signature,
603 bar lines) in the score.
604
605 @item fragment
606 Make @command{lilypond-book} add some boilerplate code so that you can
607 simply enter, say,
608
609 @example
610 c'4
611 @end example
612
613 @noindent
614 without @code{\layout}, @code{\score}, etc.
615
616 @item nofragment
617 Do not add additional code to complete LilyPond code in music snippets.
618 Since this is the default, @code{nofragment} is redundant normally.
619
620 @item indent=@var{size}\@var{unit}
621 Set indentation of the first music system to @var{size}, using
622 @var{unit} as units.  @var{unit} is one of the following strings:
623 @code{cm}, @code{mm}, @code{in}, or @code{pt}.  This option affects
624 LilyPond, not the text layout.
625
626 @item noindent
627 Set indentation of the first music system to zero.  This option affects
628 LilyPond, not the text layout.  Since no indentation is the default,
629 @code{noindent} is redundant normally.
630
631 @item quote
632 Reduce line length of a music snippet by @math{2*0.4}@dmn{in} and put
633 the output into a quotation block.  The value @q{0.4@dmn{in}} can be
634 controlled with the @code{exampleindent} option.
635
636 @item exampleindent
637 Set the amount by which the @code{quote} option indents a music snippet.
638
639 @item relative
640 @itemx relative=@var{n}
641 Use relative octave mode.  By default, notes are specified relative to
642 middle@tie{}C.  The optional integer argument specifies the octave of
643 the starting note, where the default @code{1} is middle C.
644 @code{relative} option only works when @code{fragment} option is set,
645 so @code{fragment} is automatically implied by @code{relative},
646 regardless of the presence of any @code{(no)fragment} option in the
647 source.
648 @end table
649
650 LilyPond also uses @command{lilypond-book} to produce its own
651 documentation.  To do that, some more obscure music fragment options are
652 available.
653
654 @table @code
655 @item verbatim
656 The argument of a LilyPond command is copied to the output file and
657 enclosed in a verbatim block, followed by any text given with the
658 @code{intertext} option (not implemented yet); then the actual music is
659 displayed.  This option does not work well with @code{\lilypond@{@}} if
660 it is part of a paragraph.
661
662 If @code{verbatim} is used in a @code{lilypondfile} command, it is
663 possible to enclose verbatim only a part of the source file.  If the
664 source file contain a comment containing @samp{begin verbatim} (without
665 quotes), quoting the source in the verbatim block will start after the
666 last occurrence of such a comment; similarly, quoting the source verbatim
667 will stop just before the first occurrence of a comment containing
668 @samp{end verbatim}, if there is any.  In the following source file
669 example, the music will be interpreted in relative mode, but the
670 verbatim quote will not show the @code{relative} block, i.e.
671
672 @example
673 \relative c' @{ % begin verbatim
674   c4 e2 g4
675   f2 e % end verbatim
676 @}
677 @end example
678
679 @noindent
680 will be printed with a verbatim block like
681
682 @example
683   c4 e2 g4
684   f2 e
685 @end example
686
687 @noindent
688 If you would like to translate comments and variable names in verbatim
689 output but not in the sources, you may set the environment variable
690 @code{LYDOC_LOCALEDIR} to a directory path; the directory should
691 contain a tree of @file{.mo} message catalogs with @code{lilypond-doc}
692 as a domain.
693
694 @item addversion
695 (Only for Texinfo output.)  Prepend line @code{\version
696 @@w@{"@@version@{@}"@}} to @code{verbatim} output.
697
698 @item texidoc
699 (Only for Texinfo output.)  If @command{lilypond} is called with the
700 @option{--header=@/texidoc} option, and the file to be processed is
701 called @file{foo.ly}, it creates a file @file{foo.texidoc} if there
702 is a @code{texidoc} field in the @code{\header}.  The @code{texidoc}
703 option makes @command{lilypond-book} include such files, adding its
704 contents as a documentation block right before the music snippet.
705
706 Assuming the file @file{foo.ly} contains
707
708 @example
709 \header @{
710   texidoc = "This file demonstrates a single note."
711 @}
712 @{ c'4 @}
713 @end example
714
715 @noindent
716 and we have this in our Texinfo document @file{test.texinfo}
717
718 @example
719 @@lilypondfile[texidoc]@{foo.ly@}
720 @end example
721
722 @noindent
723 the following command line gives the expected result
724
725 @example
726 lilypond-book --pdf --process="lilypond \
727   -dbackend=eps --header=texidoc" test.texinfo
728 @end example
729
730 Most LilyPond test documents (in the @file{input} directory of the
731 distribution) are small @file{.ly} files which look exactly like this.
732
733 For localization purpose, if the Texinfo document contains
734 @code{@@documentlanguage @var{LANG}} and @file{foo.ly} header
735 contains a @code{texidoc@var{LANG}} field, and if @command{lilypond}
736 is called with @option{--header=@/texidoc@var{LANG}}, then
737 @file{foo.texidoc@var{LANG}} will be included instead of
738 @file{foo.texidoc}.
739
740 @item doctitle
741 (Only for Texinfo output.) This option works similarly to
742 @code{texidoc} option: if @command{lilypond} is called with the
743 @option{--header=@/doctitle} option, and the file to be processed is
744 called @file{foo.ly} and contains a @code{doctitle} field in the
745 @code{\header}, it creates a file @file{foo.doctitle}.  When
746 @code{doctitle} option is used, the contents of @file{foo.doctitle},
747 which should be a single line of @var{text}, is inserted in the
748 Texinfo document as @code{@@lydoctitle @var{text}}.
749 @code{@@lydoctitle} should be a macro defined in the Texinfo document.
750 The same remark about @code{texidoc} processing with localized
751 languages also applies to @code{doctitle}.
752
753 @item nogettext
754 (Only for Texinfo output.) Do not translate comments and variable
755 names in the snippet quoted verbatim.
756
757 @item printfilename
758 If a LilyPond input file is included with @code{\lilypondfile}, print
759 the file name right before the music snippet.  For HTML output, this
760 is a link.  Only the base name of the file is printed, i.e. the
761 directory part of the file path is stripped.
762
763 @end table
764
765
766 @node Invoking lilypond-book
767 @section Invoking @command{lilypond-book}
768
769 @command{lilypond-book} produces a file with one of the following
770 extensions: @file{.tex}, @file{.texi}, @file{.html} or @file{.xml},
771 depending on the output format.  All of @file{.tex}, @file{.texi} and
772 @file{.xml} files need further processing.
773
774 @subheading Format-specific instructions
775
776 @subsubheading @LaTeX{}
777
778 There are two ways of processing your @LaTeX{} document for printing or
779 publishing: getting a PDF file directly with PDF@LaTeX{}, or getting a
780 PostScript file with @LaTeX{} via a DVI to PostScript translator like
781 @command{dvips}.  The first way is simpler and recommended@footnote{Note
782 that PDF@LaTeX{} and @LaTeX{} may not be both usable to compile any
783 @LaTeX{} document, that is why we explain the two ways.}, and whichever
784 way you use, you can easily convert between PostScript and PDF with
785 tools, like @command{ps2pdf} and @command{pdf2ps} included in
786 Ghostscript package.
787
788 To produce a PDF file through PDF@LaTeX{}, use
789
790 @example
791 lilypond-book --pdf yourfile.lytex
792 pdflatex yourfile.tex
793 @end example
794
795 @cindex outline fonts
796 @cindex type1 fonts
797 @cindex dvips
798 @cindex invoking dvips
799 To produce PDF output via @LaTeX{}/@command{dvips}/@command{ps2pdf}, you
800 should do
801
802 @example
803 lilypond-book yourfile.lytex
804 latex yourfile.tex
805 dvips -Ppdf yourfile.dvi
806 ps2pdf yourfile.ps
807 @end example
808
809 @noindent
810 The @file{.dvi} file created by this process will not contain
811  note heads.  This is normal; if you follow the instructions, they
812 will be included in the @file{.ps} and @file{.pdf} files.
813
814 Running @command{dvips} may produce some warnings about fonts; these
815 are harmless and may be ignored.  If you are running @command{latex} in
816 twocolumn mode, remember to add @code{-t landscape} to the
817 @command{dvips} options.
818
819 @subsubheading Texinfo
820
821 To produce a Texinfo document (in any output format), follow the normal
822 procedures for Texinfo; this is, either call @command{texi2pdf} or
823 @command{texi2dvi} or @command{makeinfo}, depending on the output format
824 you want to create.
825 @ifinfo
826 @xref{Format with texi2dvi, , , texinfo, GNU Texinfo}, and @ref{Creating
827 an Info File, , , texinfo, GNU Texinfo}.
828 @end ifinfo
829 @ifnotinfo
830 See the documentation of Texinfo for further details.
831 @end ifnotinfo
832
833
834 @subheading Command line options
835
836 @command{lilypond-book} accepts the following command line options:
837
838 @table @code
839 @item -f @var{format}
840 @itemx --format=@var{format}
841 Specify the document type to process: @code{html}, @code{latex},
842 @code{texi} (the default) or @code{docbook}.  If this option is missing,
843 @command{lilypond-book} tries to detect the format automatically, see
844 @ref{Filename extensions}.  Currently, @code{texi} is the same as
845 @code{texi-html}.
846
847 @c This complicated detail is not implemented, comment it out -jm
848 @ignore
849 The @code{texi} document type produces a Texinfo file with music
850 fragments in the printed output only.  For getting images in the HTML
851 version, the format @code{texi-html} must be used instead.
852 @end ignore
853
854 @item -F @var{filter}
855 @itemx --filter=@var{filter}
856 Pipe snippets through @var{filter}.  @code{lilypond-book} will
857 not --filter and --process at the same time.  For example,
858
859 @example
860 lilypond-book --filter='convert-ly --from=2.0.0 -' my-book.tely
861 @end example
862
863 @item -h
864 @itemx --help
865 Print a short help message.
866
867 @item -I @var{dir}
868 @itemx --include=@var{dir}
869 Add @var{dir} to the include path.  @command{lilypond-book} also looks
870 for already compiled snippets in the include path, and does not write
871 them back to the output directory, so in some cases it is necessary to
872 invoke further processing commands such as @command{makeinfo} or
873 @command{latex} with the same @code{-I @var{dir}} options.
874
875 @item -o @var{dir}
876 @itemx --output=@var{dir}
877 Place generated files in directory @var{dir}.  Running
878 @command{lilypond-book} generates lots of small files that LilyPond will
879 process.  To avoid all that garbage in the source directory, use the
880 @option{--output} command line option, and change to that directory
881 before running @command{latex} or @command{makeinfo}.
882
883 @example
884 lilypond-book --output=out yourfile.lytex
885 cd out
886 ...
887 @end example
888
889 @itemx --skip-lily-check
890 Do not fail if no lilypond output is found.  It is used for LilyPond
891 Info documentation without images.
892
893 @itemx --skip-png-check
894 Do not fail if no PNG images are found for EPS files.  It is used for
895 LilyPond Info documentation without images.
896
897 @itemx --lily-output-dir=@var{dir}
898 Write lily-XXX files to directory @var{dir}, link into @code{--output}
899 directory.  Use this option to save building time for documents in
900 different directories which share a lot of identical snippets.
901
902 @itemx --info-images-dir=@var{dir}
903 Format Texinfo output so that Info will look for images of music in
904 @var{dir}.
905
906 @itemx --latex-program=@var{prog}
907 Run executable @command{prog} instead of @command{latex}.  This is
908 useful if your document is processed with @command{xelatex}, for
909 example.
910
911 @itemx --left-padding=@var{amount}
912 Pad EPS boxes by this much.  @var{amount} is measured in millimeters,
913 and is 3.0 by default.  This option should be used if the lines of
914 music stick out of the right margin.
915
916 The width of a tightly clipped system can vary, due to notation
917 elements that stick into the left margin, such as bar numbers and
918 instrument names.  This option will shorten each line and move each
919 line to the right by the same amount.
920
921 @item -P @var{command}
922 @itemx --process=@var{command}
923 Process LilyPond snippets using @var{command}.  The default command is
924 @code{lilypond}.  @code{lilypond-book} will not @code{--filter} and
925 @code{--process} at the same time.
926
927 @item --pdf
928 Create PDF files for use with PDF@LaTeX{}.
929
930 @itemx --use-source-file-names
931 Write snippet output files with the same base name as their source file.
932 This option works only for snippets included with @code{lilypondfile}
933 and only if directories implied by @code{--output-dir} and
934 @code{--lily-output-dir} options are different.
935
936 @item -V
937 @itemx --verbose
938 Be verbose.
939
940 @item -v
941 @itemx --version
942 Print version information.
943 @end table
944
945 @knownissues
946
947 The Texinfo command @code{@@pagesizes} is not interpreted.  Similarly,
948 @LaTeX{} commands that change margins and line widths after the preamble
949 are ignored.
950
951 Only the first @code{\score} of a LilyPond block is processed.
952
953
954 @node Filename extensions
955 @section Filename extensions
956
957 You can use any filename extension for the input file, but if you do not
958 use the recommended extension for a particular format you may need to
959 manually specify the output format; for details, see @ref{Invoking
960 lilypond-book}.  Otherwise, @command{lilypond-book} automatically
961 selects the output format based on the input filename's extension.
962
963 @quotation
964 @multitable @columnfractions .2 .5
965 @item @strong{extension} @tab @strong{output format}
966 @item
967 @item @file{.html} @tab HTML
968 @item @file{.htmly} @tab HTML
969 @item @file{.itely} @tab Texinfo
970 @item @file{.latex} @tab @LaTeX{}
971 @item @file{.lytex} @tab @LaTeX{}
972 @item @file{.lyxml} @tab DocBook
973 @item @file{.tely} @tab Texinfo
974 @item @file{.tex} @tab @LaTeX{}
975 @item @file{.texi} @tab Texinfo
976 @item @file{.texinfo} @tab Texinfo
977 @item @file{.xml} @tab HTML
978 @end multitable
979 @end quotation
980
981 If you use the same filename extension for the input file than the
982 extension @command{lilypond-book} uses for the output file, and if the
983 input file is in the same directory as @command{lilypond-book} working
984 directory, you must use @code{--output} option to make
985 @command{lilypond-book} running, otherwise it will exit with an error
986 message like @qq{Output would overwrite input file}.
987
988
989 @node lilypond-book templates
990 @section lilypond-book templates
991
992 These templates are for use with @code{lilypond-book}.  If you're not familiar
993 with this program, please refer to
994 @ref{lilypond-book}.
995
996 @subsection LaTeX
997
998 You can include LilyPond fragments in a LaTeX document.
999
1000 @example
1001 \documentclass[]@{article@}
1002
1003 \begin@{document@}
1004
1005 Normal LaTeX text.
1006
1007 \begin@{lilypond@}
1008 \relative c'' @{
1009   a4 b c d
1010 @}
1011 \end@{lilypond@}
1012
1013 More LaTeX text, and options in square brackets.
1014
1015 \begin@{lilypond@}[fragment,relative=2,quote,staffsize=26,verbatim]
1016 d4 c b a
1017 \end@{lilypond@}
1018 \end@{document@}
1019 @end example
1020
1021 @subsection Texinfo
1022
1023 You can include LilyPond fragments in Texinfo; in fact, this entire manual
1024 is written in Texinfo.
1025
1026 @example
1027 \input texinfo @c -*-texinfo-*-
1028 @@node Top
1029 @@top
1030
1031 Texinfo text
1032
1033 @@lilypond
1034 \relative c' @{
1035   a4 b c d
1036 @}
1037 @@end lilypond
1038
1039 More Texinfo text, and options in brackets.
1040
1041 @@lilypond[verbatim,fragment,ragged-right]
1042 d4 c b a
1043 @@end lilypond
1044
1045 @@bye
1046 @end example
1047
1048
1049 @subsection html
1050
1051 @example
1052 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
1053 <!-- header_tag -->
1054 <HTML>
1055 <body>
1056
1057 <p>
1058 Documents for lilypond-book may freely mix music and text.  For
1059 example,
1060 <lilypond>
1061 \relative c'' @{
1062   a4 b c d
1063 @}
1064 </lilypond>
1065 </p>
1066
1067 <p>
1068 Another bit of lilypond, this time with options:
1069
1070 <lilypond fragment quote staffsize=26 verbatim>
1071 a4 b c d
1072 </lilypond>
1073 </p>
1074
1075 </body>
1076 </html>
1077
1078
1079 @end example
1080
1081 @subsection xelatex
1082
1083 @verbatim
1084 \documentclass{article}
1085 \usepackage{ifxetex}
1086 \ifxetex
1087 %xetex specific stuff
1088 \usepackage{xunicode,fontspec,xltxtra}
1089 \setmainfont[Numbers=OldStyle]{Times New Roman}
1090 \setsansfont{Arial}
1091 \else
1092 %This can be empty if you are not going to use pdftex
1093 \usepackage[T1]{fontenc}
1094 \usepackage[utf8]{inputenc}
1095 \usepackage{mathptmx}%Times
1096 \usepackage{helvet}%Helvetica
1097 \fi
1098 %Here you can insert all packages that pdftex also understands
1099 \usepackage[ngerman,finnish,english]{babel}
1100 \usepackage{graphicx}
1101
1102 \begin{document}
1103 \title{A short document with LilyPond and xelatex}
1104 \maketitle
1105
1106 Normal \textbf{font} commands inside the \emph{text} work,
1107 because they \textsf{are supported by \LaTeX{} and XeteX.}
1108 If you want to use specific commands like \verb+\XeTeX+, you
1109 should include them again in a \verb+\ifxetex+ environment.
1110 You can use this to print the \ifxetex \XeTeX{} command \else
1111 XeTeX command \fi which is not known to normal \LaTeX .
1112
1113 In normal text you can easily use LilyPond commands, like this:
1114
1115 \begin{lilypond}
1116 {a2 b c'8 c' c' c'}
1117 \end{lilypond}
1118
1119 \noindent
1120 and so on.
1121
1122 The fonts of snippets set with LilyPond will have to be set from
1123 inside
1124 of the snippet.  For this you should read the AU on how to use
1125 lilypond-book.
1126
1127 \selectlanguage{ngerman}
1128 Auch Umlaute funktionieren ohne die \LaTeX -Befehle, wie auch alle
1129 anderen
1130 seltsamen Zeichen: __ ______, wenn sie von der Schriftart
1131 unterst__tzt werden.
1132 \end{document}
1133 @end verbatim
1134
1135
1136 @node Sharing the table of contents
1137 @section Sharing the table of contents
1138
1139 These functions already exist in the OrchestralLily package:
1140
1141 @example
1142 @url{http://repo.or.cz/w/orchestrallily.git}
1143 @end example
1144
1145 For greater flexibility in text handling, some users prefer to
1146 export the table of contents from lilypond and read it into
1147 @LaTeX{}.
1148
1149 @subsubheading Exporting the ToC from LilyPond
1150
1151 This assumes that your score has multiple movements in the same lilypond
1152 output file.
1153
1154 @smallexample
1155 #(define (oly:create-toc-file layout pages)
1156   (let* ((label-table (ly:output-def-lookup layout 'label-page-table)))
1157     (if (not (null? label-table))
1158       (let* ((format-line (lambda (toc-item)
1159              (let* ((label (car toc-item))
1160                     (text  (caddr toc-item))
1161                     (label-page (and (list? label-table)
1162                                      (assoc label label-table)))
1163                     (page (and label-page (cdr label-page))))
1164                (format #f "~a, section, 1, @{~a@}, ~a" page text label))))
1165              (formatted-toc-items (map format-line (toc-items)))
1166              (whole-string (string-join formatted-toc-items ",\n"))
1167              (output-name (ly:parser-output-name parser))
1168              (outfilename (format "~a.toc" output-name))
1169              (outfile (open-output-file outfilename)))
1170         (if (output-port? outfile)
1171             (display whole-string outfile)
1172             (ly:warning (_ "Unable to open output file ~a for the TOC information") outfilename))
1173         (close-output-port outfile)))))
1174
1175 \paper @{
1176   #(define (page-post-process layout pages) (oly:create-toc-file layout pages))
1177 @}
1178 @end smallexample
1179
1180 @subsubheading Importing the ToC into LaTeX
1181
1182 In LaTeX, the header should include:
1183
1184 @c no, this doesn't require the smallexample, but since the other
1185 @c two blocks on this page use it, I figured I might as well
1186 @c user it here as well, for consistency. -gp
1187 @smallexample
1188 \usepackage@{pdfpages@}
1189 \includescore@{nameofthescore@}
1190 @end smallexample
1191
1192 @noindent
1193 where @code{\includescore} is defined as:
1194
1195 @smallexample
1196 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1197 % \includescore@{PossibleExtension@}
1198 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1199
1200 % Read in the TOC entries for a PDF file from the corresponding .toc file.
1201 % This requires some heave latex tweaking, since reading in things from a file
1202 % and inserting it into the arguments of a macro is not (easily) possible
1203
1204 % Solution by Patrick Fimml on #latex on April 18, 2009:
1205 % \readfile@{filename@}@{\variable@}
1206 % reads in the contents of the file into \variable (undefined if file
1207 % doesn't exist)
1208 \newread\readfile@@f
1209 \def\readfile@@line#1@{%
1210 @{\catcode`\^^M=10\global\read\readfile@@f to \readfile@@tmp@}%
1211 \edef\do@{\noexpand\g@@addto@@macro@{\noexpand#1@}@{\readfile@@tmp@}@}\do%
1212 \ifeof\readfile@@f\else%
1213 \readfile@@line@{#1@}%
1214 \fi%
1215 @}
1216 \def\readfile#1#2@{%
1217 \openin\readfile@@f=#1 %
1218 \ifeof\readfile@@f%
1219 \typeout@{No TOC file #1 available!@}%
1220 \else%
1221 \gdef#2@{@}%
1222 \readfile@@line@{#2@}%
1223 \fi
1224 \closein\readfile@@f%
1225 @}%
1226
1227
1228 \newcommand@{\includescore@}[1]@{
1229 \def\oly@@fname@{\oly@@basename\@@ifmtarg@{#1@}@{@}@{_#1@}@}
1230 \let\oly@@addtotoc\undefined
1231 \readfile@{\oly@@xxxxxxxxx@}@{\oly@@addtotoc@}
1232 \ifx\oly@@addtotoc\undefined
1233 \includepdf[pages=-]@{\oly@@fname@}
1234 \else
1235 \edef\includeit@{\noexpand\includepdf[pages=-,addtotoc=@{\oly@@addtotoc@}]
1236 @{\oly@@fname@}@}\includeit
1237 \fi
1238 @}
1239 @end smallexample
1240
1241
1242 @node Alternate methods of mixing text and music
1243 @section Alternative methods of mixing text and music
1244
1245 Other means of mixing text and music (without
1246 @command{lilypond-book}) are discussed in
1247 @ref{LilyPond output in other programs}.
1248
1249