]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/tutorial.itely
* scm/translation-functions.scm (fraction-tuplet-formatter):
[lilypond.git] / Documentation / user / tutorial.itely
1 @c -*-texinfo-*-
2 @c This file is part of lilypond.tely
3
4 @c TODO:
5 @c   * more details about running lilypond; error messages,
6 @c     compiling/viewing (emacs?)
7 @c   * where to go from  First steps+More basics?
8
9 @node Tutorial
10 @chapter Tutorial
11
12
13
14 Using LilyPond comes down to encoding music in an input file. After
15 entering the music, the program is run on the file producing output
16 which can be viewed or printed.  In this tutorial, we will show step
17 by step how to enter such files, and illustrate the process with
18 fragments of input and the corresponding output.  At the end of every
19 section, a paragraph will list where to find further information on
20 the topics discussed.
21
22 Many people learn programs by trying and fiddling around with the
23 program.  This is also possible with LilyPond. If you click on a
24 picture in the HTML version of this manual, you will see the exact
25 LilyPond input that was used to generate that image.
26 @ifhtml
27 For example, consider the following input:
28 @example
29   c'^\markup @{ \bold \huge @{ Click on this image! @} @}
30 @end example
31 @c @lily pond[relative=1,raggedright,with the following output:]
32 with the following output:
33 @lilypond[relative=1,raggedright]
34   c'^\markup { \bold \huge { Click on this image! } }
35 @end lilypond
36
37 @end ifhtml
38 By cutting and pasting the full input into a test file, you have a
39 starting template for experiments. If you like learning in this way,
40 you will probably want to print out or bookmark
41 @ifhtml
42 the
43 @end ifhtml
44 @ref{Cheat sheet}, which is a table listing all commands for quick
45 reference.
46
47
48 This tutorial starts with a short introduction to the LilyPond music
49 language.  After this first contact, we will show you how to to
50 produce printed output.  You should then be able to create and print
51 your first sheets of music.
52
53 @menu
54 * First steps::                 
55 * Running LilyPond::            
56 * More about pitches::          
57 * Entering ties::               
58 * Automatic and manual beams::  
59 * Octave entry::                
60 * Music expressions explained::  
61 * More staves::                 
62 * Adding articulation marks to notes::  
63 * Combining notes into chords::  
64 * Basic rhythmical commands::   
65 * Commenting input files::      
66 * Printing lyrics::             
67 * A lead sheet::                
68 * Listening to output::         
69 * Titling::                     
70 * Single staff polyphony::      
71 * Piano staves::                
72 * Organizing larger pieces::    
73 * An orchestral part::          
74 * Integrating text and music::  
75 @end menu
76
77
78 @node First steps
79 @section First steps
80
81 We start off by showing how very simple music is entered in LilyPond.
82 A note is entered by typing its name, from @samp{a} through @samp{g},
83 and a number.  So, if you enter
84
85 @example
86 c4 d4 e4 f4
87 @end example
88
89 @noindent
90 then the result looks like this:
91
92 @lilypond[notime,relative]
93 c4 d4 e4 f4
94 @end lilypond
95
96 The number specifies the length of the note, @samp{1} for a
97 @rglos{whole note}, @samp{2} for a @rglos{half note}, and so on:
98
99 @example
100 a1 a2 a4 a16 a32
101 @end example
102
103 @lilypond[notime]
104 \set Score.timing = ##f
105 \set Staff.autoBeaming = ##f
106 \transpose c c' { a1 a2 a4 a16 a32 s16_" " }
107 @end lilypond
108
109 If you do not specify a @rglos{duration}, the the first note is a
110 quarter, and for others, the last entered duration is used.
111
112 @example
113 a4 a a2 a
114 @end example
115
116 @lilypond[notime]
117 \set Score.timing = ##f
118 \transpose c c' { a a a2 a s16_" " }
119 @end lilypond
120
121
122 Rests are entered just like notes, but with the name ``@code{r}'':
123
124 @cindex rests
125 @quotation
126 @example
127 r2 r4 r8 r16
128 @end example
129
130 @lilypond[fragment]
131 \set Score.timing = ##f
132 \set Staff.Clef = \turnOff
133 \set Staff.TimeSignature = \turnOff
134 r2 r4 r8 r16
135 s16_" "
136 @end lilypond
137 @end quotation
138 @separate
139
140
141 Add a dot @samp{.} after the duration to get a @rglos{dotted note}:
142
143 @example
144 a2. a4 a8. a16
145 @end example
146
147 @lilypond[notime]
148 \set Score.timing = ##f
149 \transpose c c' { a2. a4 a8. a16 s16_" " }
150 @end lilypond
151
152
153 The @rglos{meter} (or @rglos{time signature}) can be set with the
154 @code{\time} command:
155
156 @example
157 \time 3/4
158 \time 6/8
159 \time 4/4
160 @end example
161
162 @c a clef here may lead to confusion
163 @lilypond
164 \override Staff.Clef #'transparent = ##t 
165 \time 3/4
166 s4_" "
167 \time 6/8
168 s4_" "
169 \time 4/4
170 s16_" "
171 @end lilypond
172
173
174 The @rglos{clef} can be set using the @code{\clef} command:
175
176 @c what is more common name treble or violin?
177 @c in Dutch, it's violin.
178 @c in English it's definitely treble.
179 @example
180 \clef treble
181 \clef bass
182 \clef alto
183 \clef tenor
184 @end example
185
186 @lilypond[notime]
187 \set Score.timing = ##f
188 \clef violin
189 s4_" "
190 \clef bass
191 s4_" "
192 \clef alto
193 s4_" "
194 \clef tenor
195 s16_" "
196 @end lilypond
197
198 To recognize names like @code{c} and @code{d} as pitches, they have to
199 be entered inside a so-called @code{\notes} block.  This block is
200 formed by enclosing notes and commands are enclosed in curly braces,
201
202 @example
203 @{
204   \time 3/4
205   \clef bass
206   c2 e4 g2.
207   f4 e d c2 r4
208 @}
209 @end example
210 and adding the keyword @code{\notes} before the opening brace
211 @code{@{}, for example,
212
213 @example
214 \notes @{
215   \time 3/4
216   \clef bass
217   c2 e4 g2.
218   f4 e d c2 r4
219 @}
220 @end example
221
222 Now the piece of music is almost ready to be printed.  When this
223 enclosed a @code{\score} block, i.e. braces @code{@{ @dots{} @}} with 
224 keyword @code{\score} in front, like 
225
226 @example
227 \score @{
228   \notes @{
229     \time 3/4
230     \clef bass
231     c2 e4 g2.
232     f4 e d c2 r4
233   @}
234 @}
235 @end example
236
237 then the music will be converted to printable output:
238
239 @lilypond[noindent]
240 \score {
241   \notes {
242      \time 3/4
243      \clef bass
244      c2 e4 g2.
245      f4 e d c2 r4
246   }
247   \paper {
248     linewidth = 55 * \staffspace
249   }
250 }
251 @end lilypond
252
253 In many examples in this manual, both @code{\score} and @code{\notes}
254 and accompanying braces are left out for brevity. However, they must
255 be present when feeding the file to LilyPond.
256
257 For more elaborate information on
258
259 @table @asis
260 @item  Entering pitches and durations
261 see 
262 @ref{Pitches} and @ref{Durations}.
263 @item Clefs
264 see @ref{Clef}
265 @item Rests
266 see @ref{Rests}. 
267 @item Time signatures and other timing commands
268 see  @ref{Time signature}.
269 @end table 
270
271 @node Running LilyPond
272 @section Running LilyPond
273
274 In the last section we explained what kind of things you could enter
275 in a LilyPond file.  In this section we will explain what commands to run
276 and how to view or print the output.  If you have not used LilyPond
277 before, want to test your setup, or want to run an example file
278 yourself, read this section.  The instructions that follow are for
279 Unix-like systems.  Some additional instructions for Microsoft Windows
280 are given at the end of this section.
281
282 Begin by opening a terminal window and starting a text editor.  For
283 example, you could open an xterm and execute
284 @code{joe}.@footnote{There are macro files for VIM addicts, and there
285 is a @code{LilyPond-mode} for Emacs addicts. If it has not been
286 installed already, then refer to the file @file{INSTALL.txt}}.  In
287 your text editor, enter the following input and save the file as
288 @file{test.ly}:
289
290 @quotation
291 @example
292 \score @{
293   \notes @{ c'4 e' g' @}
294 @} 
295 @end example
296 @end quotation
297
298 To process @file{test.ly}, proceed as follows:
299
300 @quotation
301 @example
302 lilypond test.ly
303 @end example
304 @end quotation
305
306 You will see something resembling:
307
308 @quotation
309 @example
310 GNU LilyPond 1.8.0
311 Now processing: `/home/fred/ly/test.ly'
312 Parsing...
313 Interpreting music...[1]
314  @emph{ ... more interesting stuff ... }
315 PDF output to `test.pdf'...
316 DVI output to `test.dvi'...
317 @end example
318 @end quotation
319 @cindex DVI file
320 @cindex Viewing music
321 @cindex xdvi
322
323 The result is the file @file{test.pdf}@footnote{For @TeX{}
324 afficionados: there is also a @file{test.dvi} file. It can be viewed
325 with @code{xdvi}. The DVI uses a lot of PostScript specials, which do
326 not show up in the magnifying glass. The specials also mean that the
327 DVI file cannot be processed with @code{dvilj}. Use @code{dvips} for
328 printing.
329 @cindex dvips
330 @cindex dvilj
331 @cindex DVI driver
332 } which you can print or with the standard facilities of your
333 operating system.@footnote{If your system does not have any tools
334 installed, you can try @uref{Ghostscript,
335 http://www.cs.wisc.edu/~ghost/}, a freely available package for
336 viewing and printing PDF and PostScript files.}
337
338 On Windows, start up a text-editor@footnote{Any programmer-oriented
339 editor will do, for example NotePad. Do not use word processor.  Its
340 formatting codes will confuse LilyPond} and enter
341
342
343 @quotation
344 @example
345 \score @{
346   \notes @{ c'4 e' g' @}
347 @} 
348 @end example
349 @end quotation
350
351 Save it on the desktop as @file{test.ly} and make sure that it is not
352 called @file{test.ly.TXT}. Double clicking @file{test.ly} will process
353 the file and show the resulting PDF file.
354
355
356 @node More about pitches
357 @section More about pitches 
358
359 A @rglos{sharp} (@texisharp{}) pitch is made by adding @samp{is} to
360 the name, a @rglos{flat} (@texiflat{}) pitch by adding @samp{es}.  As
361 you might expect, a @rglos{double sharp} or @rglos{double flat} is
362 made by adding @samp{isis} or @samp{eses}:@footnote{This syntax
363 derived from note naming conventions in Nordic and Germanic languages,
364 like German and Dutch.}
365
366 @example
367 cis1 ees fisis aeses
368 @end example
369
370 @lilypond[notime]
371 \set Score.timing = ##f
372 \transpose c c' { cis1 ees fisis aeses s16_" " }
373 @end lilypond
374
375  
376 @cindex key signature, setting
377
378 The key signature is set with the command ``@code{\key}'', followed by
379 a pitch and @code{\major} or @code{\minor}:
380 @quotation
381 @example
382 \key d \major
383 g1
384 \key c \minor
385 g
386 @end example
387
388 @lilypond[fragment]
389 \set Staff.TimeSignature = \turnOff
390 \key d \major
391 g'1
392 \key c \minor
393 g'
394 @end lilypond
395 @end quotation
396
397
398 Key signatures together with the pitches (including alterations) are
399 used together to determine when to print accidentals.  This is a
400 feature that often causes confusion to newcomers, so let us explain it
401 in more detail:
402
403
404 LilyPond makes a sharp distinction between musical content and
405 layout. The alteration (flat, natural or sharp) of a note is part of
406 the pitch, and is therefore musical content. Whether an accidental (a
407 flat, natural or sharp @emph{sign}) is a printed in front of the
408 corresponding note is a question of layout. Layout is something that
409 follows rules, so accidentals are printed automatically according to
410 those rules.  The pitches in your music are works of art, so they will
411 not be added automatically, and you must enter what you want to hear.
412
413 In this example
414
415 @lilypond[fragment]
416 \set Staff.TimeSignature = \turnOff
417 \key d \major
418 d' cis' fis'
419 @end lilypond
420
421 @noindent
422 no note gets an explicit accidental, but still you enter
423
424 @example
425 \key d \major
426 d cis fis
427 @end example
428
429 The code @code{d} does not mean ``print a black dot just below the
430 staff.'' Rather, it means: ``a note with pitch D-natural.'' In the key
431 of A-flat, it does get an accidental:
432
433 @lilypond[fragment]
434 \set Staff.TimeSignature = \turnOff
435 \key as \major
436 d'
437 @end lilypond
438
439 @noindent
440 @example
441 \key as \major
442 d
443 @end example
444
445 Adding all alterations explicitly might require a little more effort
446 when typing, but the advantage is that transposing is easier, and
447 music can be printed according to different conventions.  See
448 @ref{Accidentals} for some examples how accidentals can be printed
449 according to different rules.
450
451
452 For more information on
453  
454 @table @asis
455 @item Accidentals
456 see @ref{Accidentals}
457
458 @item Key signature
459 see @ref{Key signature}
460 @end table
461
462 @node Entering ties
463 @section Entering ties
464
465 @cindex tie
466 A tie is created by adding a tilde ``@code{~}'' to the first note
467 being tied:
468 @quotation
469 @lilypond[fragment,verbatim,relative=2]
470 g4~ g a2~ a4
471 @end lilypond
472 @end quotation
473 @separate
474
475
476 For more information on Ties, see @ref{Ties}.
477
478
479
480 @node Automatic and manual beams
481 @section Automatic and manual beams
482
483 @cindex beams, by hand 
484 Beams are drawn automatically
485
486
487 @quotation
488 @lilypond[fragment,relative=1,verbatim]
489   a8 ais d es r d
490 @end lilypond
491 @end quotation
492 @separate
493
494 If you do not like where beams are put, they can be entered by
495 hand. Mark the first note to be beamed with @code{[} and the last one
496 with @code{]}.
497
498
499 @quotation
500 @lilypond[fragment,relative=1,verbatim]
501   a8[ ais] d[ es r d]
502 @end lilypond
503 @end quotation
504 @separate
505
506 For more information on beams, see @ref{Beaming}.
507
508
509 Here are key signatures, accidentals and ties in action:
510
511 @quotation
512 @example
513 \score @{
514   \notes @{
515     \time 4/4
516     \key g \minor
517     \clef violin
518     r4 r8 a8 gis4 b
519     g8 d4.~ d e8
520     fis4 fis8 fis8 eis4  a8 gis~
521     gis2 r2
522   @}
523 @}
524 @end example
525
526 @lilypond
527 \score {
528   \notes { \transpose c c' { 
529     \time 4/4
530     \key g \minor
531     \clef violin
532     r4 r8 a8 gis4 b
533     a8 d4.~ d e8
534     fis4 fis8 fis8 eis4  a8 gis~
535     gis2 r2
536   }}
537   \paper { linewidth = #(* 50 staffspace) }
538 }
539 @end lilypond
540 @end quotation
541 @cindex accidentals
542
543 There are some interesting points to note in this example.  Bar lines
544 and beams are drawn automatically.  Line breaks are calculated
545 automatically; it does not matter where the line breaks are in the
546 source file. Finally, the order in which time, key and clef changes
547 are entered is not relevant: in the printout, these are ordered
548 according to standard notation conventions.
549
550
551
552 @node Octave entry
553 @section Octave entry
554
555
556 @c Tim wants to move this quotes example just before the: quotes-do not-work
557 @c score, but we'd need to remove quotes from the other two (key and
558 @c tie) examples...
559
560 @c better to have this just before the `octaves are bad' snipped
561 @c but we'd need to remove the ', from \key and tie 
562 To raise a note by an octave, add a high quote @code{'} (apostrophe) to
563 the note name, to lower a note one octave, add a ``low quote'' @code{,}
564 (a comma).  Middle C is @code{c'}:
565
566 @quotation
567 @example
568 c'4 c'' c''' \clef bass c c,
569 @end example
570
571 @lilypond[fragment]
572 \set Score.timing = ##f
573 \set Staff.TimeSignature = \turnOff
574 c'4 c'' c''' \clef bass c c,
575 @end lilypond
576 @end quotation
577 @separate
578
579 An example of the use of quotes is in the following Mozart fragment:
580 @lilypond[raggedright,fragment,verbatim]
581   \key a \major
582   \time 6/8
583   cis''8. d''16 cis''8 e''4 e''8
584   b'8. cis''16 b'8 d''4 d''8 
585 @end lilypond 
586
587 This example shows that music in a high register needs lots of quotes.
588 This makes the input less readable, and it is a source of errors.  The
589 solution is to use ``relative octave'' mode.  In practice, this is the
590 most convenient way to copy existing music.  To use relative mode, add
591 @code{\relative} before the piece of music.  You must also give a note
592 from which relative starts, in this case @code{c''}.  If you do not
593 use octavation quotes (i.e. do not add @code{'} or @code{,} after a
594 note), relative mode chooses the note that is closest to the previous
595 one.  For example, @code{c f} goes up while @code{c g} goes down:
596
597 @quotation
598 @example
599 \relative c'' @{
600   c f c g c
601 @}
602 @end example
603
604 @lilypond[fragment]
605 \set Score.timing = ##f
606 \set Staff.TimeSignature = \turnOff
607 \relative c'' {
608   c f c g c
609 }
610 @end lilypond
611 @end quotation
612 @separate
613
614
615 Since most music has small intervals, pieces can be written almost
616 without octavation quotes in relative mode.  The previous example is
617 entered as
618 @c
619 @lilypond[raggedright,fragment,verbatim]
620 \relative c'' {
621   \key a \major
622   \time 6/8
623   cis8. d16 cis8 e4 e8
624   b8. cis16 b8 d4 d8
625 }
626 @end lilypond 
627
628
629 @c needed better, maybe even redundant explanation
630 @c   added another example below.
631 @c grappig: Pa vond het heel logies, en slim toen-i eenmaal begreep.
632 @c in eerste instantie drong het `relative' niet door zonder extra uitleg.
633 Larger intervals are made by adding octavation quotes.
634 @quotation
635 @example
636 \relative c'' @{
637   c f, f c' c g' c,
638 @}
639 @end example
640
641 @lilypond[fragment]
642 \set Score.timing = ##f
643 \set Staff.TimeSignature = \turnOff
644 \relative c'' {
645   c f, f c' c g' c,
646 }
647 @end lilypond
648 @end quotation
649 @separate
650
651 In @code{\relative} mode, quotes or commas no longer determine the
652 absolute height of a note. Rather, the height of a note is relative to
653 the previous one, and changing the octave of a single note shifts all
654 following notes an octave up or down.
655
656 For more information on Relative octaves see @ref{Relative octaves}
657 and @ref{Octave check}.
658
659
660 @node Music expressions explained
661 @section Music expressions explained
662
663
664 In input files, music is represent by so-called @emph{music
665 expression}. We have already seen in the previous examples; 
666 a single note is a music expression:
667
668 @lilypond[verbatim,relative=2]
669 a4
670 @end lilypond
671
672 Enclosing group of notes in braces creates a new music
673 expression: 
674  
675 @lilypond[verbatim,relative=2]
676   { a4 g4 }
677 @end lilypond
678
679 Putting a bunch of music expressions (notes) in braces, means that
680 they should be played in sequence. The result again is a music
681 expression, which can be grouped with other expressions sequentially.
682 Here, the expression from the previous example is combined with two
683 notes:
684
685 @lilypond[verbatim,relative=2]
686  { { a4 g } f g } 
687 @end lilypond
688
689 This technique becomes useful for non-monophonic music. To enter music
690 with more voices or more staves, we also combine expressions in
691 parallel. Two voices that should play at the same time, are entered as
692 a simultaneous combination of two sequences.  A ``simultaneous'' music
693 expression is formed by enclosing expressions in @code{<<} and
694 @code{>>}.  In the following example, three sequences (all contaning
695 two notes) are combined simultaneously:
696  
697 @lilypond[verbatim,relative=2]
698   <<
699      { a4 g }
700      { f e }
701      { d b }
702   >>
703 @end lilypond
704
705 This mechanism is similar to mathematical
706 formulas: a big formula is created by composing small formulas.  Such
707 formulas are called expressions, and their definition is recursive, so
708 you can make arbitrarily complex and large expressions.  For example,
709
710 @quotation
711   1
712
713   1 + 2
714   
715   (1 + 2) * 3
716   
717   ((1 + 2) * 3) / (4 * 5)
718 @end quotation
719 @cindex expression
720 @cindex music expression
721 This example shows a sequence of expressions, where each expression is
722 contained in the next one.  The simplest expressions are numbers and
723 operators (like +, * and /). Parentheses are used to group
724 expressions.
725
726 Like mathematical expressions, music expressions can be nested
727 arbitrarily deep, e.g.
728 @lilypond[verbatim,relative=1] 
729   { c <<c e>>
730       << { e f } { c <<b d>> }
731       >>
732   }
733 @end lilypond 
734
735
736
737 @cindex indent
738 When spreading expressions over multiple lines, it is customary to use
739 an indent that indicates the nesting level. Formatting music like this
740 eases reading, and helps you  insert the right number of closing
741 braces at the end of an expression. For example,
742
743 @example
744 \score @{
745   \notes <<
746     @{
747       @dots{}
748     @}
749     @{
750       @dots{}
751     @}
752   >>
753 @}
754 @end example
755
756 Some editors have special support for entering LilyPond, and can help
757 indenting source files. See @ref{Editor support} for more information.
758
759
760
761 @node More staves
762 @section More staves
763
764 To print more than one staff, each piece of music that makes up a
765 staff is marked by adding @code{\new Staff} before it.  These
766 @code{Staff}'s are then combined parallel with @code{<<} and
767 @code{>>}, as demonstrated here:
768
769 @quotation
770 @lilypond[fragment,verbatim]
771 <<
772   \new Staff { \clef violin c'' }
773   \new Staff { \clef bass c }
774 >>
775 @end lilypond
776 @end quotation
777
778
779 The command @code{\new} introduces a ``notation context.'' A notation
780 context is an environment in which musical events (like notes or
781 @code{\clef} commands) are interpreted.  For simple pieces, such
782 notation contexts are created implicitly.  For more complex pieces, it
783 is best to mark contexts explicitly. This ensures that each fragment
784 gets its own stave.
785
786 There are several types of contexts: @code{Staff}, @code{Voice} and
787 @code{Score} handle normal music notation. Other staves are also
788 @code{Lyrics} (for setting lyric texts) and @code{ChordNames} (for
789 printing chord names).
790
791
792 In terms of syntax, prepending @code{\new} to a music expression
793 creates a bigger music expression. In this way it resembles the minus
794 sign in mathematics. The formula (4+5) is an expression, so -(4+5) is a bigger
795 expression.
796
797 We can now typeset a melody with two staves:
798
799 @c TODO: (c) status of this Paul McCartney (?) song (let's all stand together)
800
801
802 @quotation
803 @lilypond[verbatim,raggedright]
804 \score {
805   \notes 
806   << \new Staff {
807       \time 3/4
808       \clef violin
809       \relative c'' {
810         e2 d4 c2 b4 a8[ a]
811         b[ b] g[ g] a2. }  
812     }
813     \new Staff {
814        \clef bass
815        c2 e4  g2.
816        f4 e d c2.
817     }
818   >>
819 }
820 @end lilypond
821 @end quotation
822
823 For more information on context see the description in
824 @ref{Interpretation context}.
825
826
827
828 @node Adding articulation marks to notes
829 @section Adding articulation marks to notes
830
831 @cindex articulation
832 @cindex accents
833 @cindex staccato
834
835 Common accents can be added to a note using a dash (`@code{-}') and a
836 single character:
837 @quotation
838 @lilypond[verbatim,relative=1]
839 c-. c-- c-> c-^ c-+ c-_
840 @end lilypond
841 @end quotation
842 @separate
843
844 @cindex fingering
845 Similarly, fingering indications can be added to a note using a dash
846 (`@code{-}') and the digit to be printed:
847 @c
848 @lilypond[verbatim,relative=1]
849   c-3 e-5 b-2 a-1
850 @end lilypond
851
852
853 Dynamic signs are made by adding the markings (with a backslash) to
854 the note:
855 @quotation
856 @lilypond[verbatim,relative=1]
857 c\ff c\mf
858 @end lilypond
859 @end quotation
860 @separate
861
862 @cindex dynamics
863 @cindex decrescendo
864 @cindex crescendo
865
866 Crescendi and decrescendi are started with the commands @code{\<} and
867 @code{\>}. An ending dynamic, for example @code{\f}, will finish the
868 crescendo, or the command @code{\!} can be used:
869 @quotation
870 @lilypond[verbatim,relative=1]
871 c2\<  c2\ff\>  c2  c2\!
872 @end lilypond
873 @end quotation
874 @separate
875
876
877
878 @cindex slur
879
880 A slur is a curve drawn across many notes, and indicates legato
881 articulation.  The starting note and ending note are marked with a
882 ``@code{(}'' and a ``@code{)}'' respectively:
883
884 @quotation
885 @lilypond[fragment,relative=1,verbatim]
886 d4( c16)( cis d e c cis d e)( d4)
887 @end lilypond
888 @end quotation
889 @separate
890 @cindex slurs versus ties
891 A slur looks like a tie, but it has a different meaning. A tie simply
892 makes the first note sound longer, and can only be used on pairs of
893 notes with the same pitch. Slurs indicate the articulations of notes,
894 and can be used on larger groups of notes. Slurs and ties are also
895 nested in practice:
896
897 @lilypond[fragment,relative=1]
898 c2~( c8 fis fis4 ~ fis2 g2)
899 @end lilypond
900
901 @cindex phrasing slurs
902 Slurs to indicate phrasing can be entered with @code{\(} and
903 @code{\)}, so you can have both legato slurs and phrasing slurs at the
904 same time.
905
906 @quotation
907 @lilypond[fragment,relative=1,verbatim]
908 a8(\( ais b  c) cis2 b'2 a4 cis,  c\)
909 @end lilypond
910 @end quotation
911
912
913 For more information on
914 @table @asis
915 @item Fingering
916   see @ref{Fingering instructions}
917 @item Articulations
918   see @ref{Articulations}
919 @item Slurs
920   see @ref{Slurs}
921 @item Phrasing slurs
922   see  @ref{Phrasing slurs}
923 @item Dynamics
924   see  @ref{Dynamics}
925 @item Fingering
926 @end table
927
928 @node Combining notes into chords
929 @section Combining notes into chords
930
931 @cindex chords
932 Chords can be made by surrounding pitches with angled brackets.
933 Angled brackets are the symbols @code{<} and @code{>}.
934
935 @quotation
936 @lilypond[relative,fragment,verbatim]
937 r4 <c e g>4 <c f a>8
938 @end lilypond
939 @end quotation
940 @separate
941
942
943 You can combine markings like beams and ties with chords.  They must
944 be placed outside the angled brackets:
945 @quotation
946 @lilypond[relative,fragment,verbatim]
947 r4 <c e g>8[ <c f a>]~ <c f a>
948 @end lilypond
949 @end quotation
950
951 @quotation
952 @example
953 r4 <c e g>8\>( <c e g> <c e g>  <c f a>8\!)
954 @end example
955 @lilypond[relative,fragment]
956 \slurUp
957 r4 <c e g>8\>( <c e g> <c e g>  <c f a>8\!)
958 @end lilypond
959 @end quotation
960 @separate
961
962
963
964
965 @node Basic rhythmical commands
966 @section  Basic rhythmical commands
967
968 @cindex pickup
969 @cindex anacruse
970 @cindex partial measure
971 A pickup is entered with the keyword @code{\partial}. It
972 is followed by a duration: @code{\partial 4} is a quarter note upstep
973 and @code{\partial 8} an eighth note:
974 @lilypond[relative=1,verbatim,fragment]
975   \partial 8
976   f8 c2 d e
977 @end lilypond
978
979 @cindex tuplets
980 @cindex triplets
981 Tuplets are made with the @code{\times} keyword.  It takes two
982 arguments: a fraction and a piece of music.  The duration of the piece
983 of music is multiplied by the fraction.  Triplets make notes occupy
984 2/3 of their notated duration, so  a triplet has  2/3 as its fraction:
985 @c
986 @lilypond[relative,verbatim,fragment]
987   \times 2/3 { f8 g a }
988   \times 2/3 { c r c }
989 @end lilypond 
990
991 @cindex grace notes
992 @cindex accacciatura
993 Grace notes are also made by prefixing a music expression with the
994 keyword @code{\appoggiatura} or @code{\acciaccatura}
995 @cindex appoggiatura
996 @cindex acciaccatura
997       
998 @lilypond[relative=1,verbatim,fragment]
999   c4 \appoggiatura b16 c4
1000   c4 \acciaccatura b16 c4
1001 @end lilypond
1002
1003 @noindent
1004
1005 For more information on
1006 @table @asis
1007 @item  grace notes
1008 see @ref{Grace notes},
1009 @item tuplets
1010 see @ref{Tuplets},
1011 @item upsteps 
1012 see @ref{Partial measures}.
1013 @end table
1014
1015
1016
1017 @node Commenting input files
1018 @section Commenting input files
1019
1020 @cindex comments
1021 @cindex line comment
1022 @cindex block comment
1023 Comments are pieces of the input that are ignored.  There are two
1024 types of comments. The percent symbol @code{%} introduces a line
1025 comment; the rest of the line is ignored.  Block comments span larger
1026 sections of input.  Anything that is enclosed in @code{%@{} and
1027 @code{%@}} is ignored too. The following fragment shows possible uses
1028 for comments:
1029
1030 @example
1031   % notes for twinkle twinkle follow:
1032   c4 c   g' g  a a
1033   
1034   %@{
1035   
1036     This line, and the notes below
1037     are ignored, since they are in a
1038     block comment.
1039
1040     g g f f e e d d c2 
1041   %@}
1042 @end example
1043
1044
1045
1046
1047 @node Printing lyrics
1048 @section Printing lyrics
1049 @cindex lyrics
1050
1051 @c TODO: (c) status of the Queen fragment.
1052
1053 @cindex Lyrics
1054 @cindex Songs
1055 Lyrics are entered by separating each syllable with a space, and
1056 surrounding them with @code{\lyrics @{ @dots{} @}}, for example,
1057 @example
1058   \lyrics @{ I want to break free @}
1059 @end example
1060
1061 Like notes, lyrics are also a form of music, but they must not be
1062 printed on a staff, which is the default way to print music. To print
1063 them as lyrics, they must be marked with @code{ \new Lyrics}:
1064 @example
1065   \new Lyrics  \lyrics @{ I want to break free @}
1066 @end example
1067 The melody for this song is as follows:
1068
1069 @lilypond[fragment,relative=1]
1070    \partial 8
1071      c8
1072    \times 2/3 {  f4 g g } \times 2/3 { g4( a2) }
1073 @end lilypond
1074
1075 The lyrics can be set to these notes, combining both with the
1076 @code{\lyricsto} keyword:
1077 @example
1078   \lyricsto "@var{name}" \new Lyrics @dots{}
1079 @end example
1080 where @var{name} identifies to which melody the lyrics should be
1081 aligned. In this case, there is only one melody, so we can leave it
1082 empty.
1083
1084 The final result is 
1085 @lilypond[verbatim,fragment]
1086 \score  {
1087  \notes <<
1088    \relative c' \new Voice {
1089      \partial 8
1090      c8
1091      \times 2/3 { f g g } \times 2/3 { g4( a2) }
1092    }
1093    \lyricsto "" \new Lyrics \lyrics { I want to break free }
1094  >>
1095 }
1096 @end lilypond
1097
1098 @cindex melisma
1099 @cindex extender line
1100 @c synonyms?
1101 This melody ends on a @rglos{melisma}, a single syllable (``free'')
1102 sung to more than one note. This is indicated with an @emph{extender
1103 line}. It is entered as two underscores, i.e.
1104 @example
1105   \lyrics @{ I want to break free __ @}
1106 @end example 
1107 @lilypond[raggedright]
1108 \score  {
1109  \notes <<
1110    \relative c' \new Voice {
1111      \partial 8
1112      c8
1113      \times 2/3 { f g g } \times 2/3 { g4( a2) } }
1114    \lyricsto "" \new Lyrics \lyrics { I want to break free __ }
1115    >>
1116 }
1117 @end lilypond
1118
1119 Similarly, hyphens between words can be entered as two dashes,
1120 resulting in a centered hyphen between two syllables:
1121 @example
1122   Twin -- kle twin -- kle
1123 @end example
1124 @lilypond[raggedright]
1125 \score {
1126   << \notes \relative f' { \time 2/4
1127     f4 f c' c' }
1128     \new Lyrics \lyrics { Twin -- kle twin -- kle }
1129   >>
1130   \paper { raggedright = ##t }
1131  }
1132 @end lilypond
1133
1134 More options, like putting multiple lines of lyrics below a melody are
1135 discussed in @ref{Vocal music}.
1136
1137
1138
1139 @node A lead sheet
1140 @section A lead sheet
1141
1142 @cindex Lead sheets
1143 @cindex chords
1144 @cindex chord names
1145  
1146 In popular music, it is common to denote accompaniment as chord-names.
1147 Using them in LilyPond has two parts, just like lyrics: entering the
1148 chords (with @code{\chords}), and printing them (with @code{\new
1149 ChordNames}).
1150
1151 Chord names are entered by starting chords mode (with @code{\chords}).
1152 In chords mode, you can enter chords with a letter (indicating the
1153 root of the chord), and a durations following that:
1154 @c
1155 @lilypond[verbatim]
1156   \chords { c2 f4. g8 } 
1157 @end lilypond
1158
1159 @noindent
1160 The result of @code{\chords} is a list of chords, and is  equivalent
1161 to entering chords with @code{<@dots{}>}.
1162
1163 Other chords can be created by adding modifiers after a colon.  The
1164 following example shows a few common modifiers:
1165 @c
1166 @lilypond[verbatim]
1167   \chords { c2 f4:m g4:maj7 gis1:dim7 }
1168 @end lilypond
1169
1170 Printing chords is done by adding @code{\new ChordNames}
1171 before the chords thus entered:
1172 @c
1173 @lilypond[verbatim]
1174  \new ChordNames \chords { c2 f4.:m g4.:maj7 gis8:dim7 }
1175 @end lilypond
1176
1177 @cindex lead sheet
1178 @separate
1179 When put together,  chord names, lyrics and a melody form
1180 a lead sheet, for example,
1181
1182 @example
1183 \score @{
1184   <<
1185     \new ChordNames \chords @{ @emph{chords} @}
1186     \notes @emph{the melody}
1187     \lyricsto "" \new Lyrics \lyrics @{ @emph{the text} @}
1188   >>
1189 @}
1190 @end example
1191 @lilypond[]
1192 \score  {
1193   << 
1194    \new ChordNames \chords { r8 c2:sus4 f } 
1195     \notes \relative c' {
1196      \partial 8
1197      c8
1198      \times 2/3 { f g g } \times 2/3 { g4( a2) } }
1199    \new Lyrics \lyricsto "" \lyrics { I want to break free __ }
1200   >>
1201  \paper{ raggedright = ##t }
1202 }
1203 @end lilypond
1204
1205
1206 A complete list of modifiers and other options for layout are in the
1207 reference manual section @ref{Chords}.
1208
1209 @node Listening to output
1210 @section Listening to output
1211
1212 @cindex sound
1213 @cindex MIDI
1214
1215 MIDI (Musical Instrument Digital Interface) is a standard for
1216 connecting and recording digital instruments.  A MIDI file is like a
1217 tape recording of a MIDI instrument. The @code{\midi} block causes LilyPond
1218 to create a MIDI file, so you can listen to the music you entered.
1219 It is great for checking the music: octaves that are off or
1220 accidentals that were mistyped stand out very much when listening to
1221 the musical transcription.
1222
1223 The @code{\midi} block is added to @code{\score}, for example,
1224 @example 
1225 \score @{
1226     @var{..music..}
1227     \midi  @{ \tempo 4=72 @}
1228 @}
1229 @end example 
1230
1231 Here, the tempo is specified using the @code{\tempo} command.  In this
1232 case the tempo of quarter notes is set to 72 beats per minute. More
1233 information on auditory output is in the @ref{Sound} section in the
1234 notation manual.
1235
1236 If there is a @code{\midi} command in a @code{\score}, then only MIDI
1237 will be produced. If notation is needed too, then a @code{\paper}
1238 block must be added too:
1239
1240 @example 
1241 \score @{
1242     @var{..music..}
1243     \midi  @{ \tempo 4=72 @}
1244     \paper @{ @}
1245 @}
1246 @end example 
1247
1248 @cindex paper block
1249
1250 @node Titling
1251 @section Titling
1252
1253 Bibliographic information is entered in a separate block, the
1254 @code{\header} block. The name of the piece, its composer, etc. are
1255 entered as an assignment, within @code{\header @{ @dots{} @}}. For
1256 example,
1257 @example 
1258   \header @{
1259     title = "Eight miniatures" 
1260     composer = "Igor Stravinsky"
1261     tagline = "small is beautiful"
1262   @}
1263   
1264   \score @{ @dots{} @}
1265 @end example
1266
1267 @cindex bibliographic information
1268 @cindex titles
1269 @cindex composer
1270 @cindex Engraved by LilyPond
1271
1272 When the file is processed by the @code{lilypond} wrapper script
1273 the title and composer specified are printed above the music. The
1274 `tagline' is a short line printed at bottom of the last page which
1275 normally says ``Engraved by LilyPond, version @dots{}''. In the
1276 example above it is replaced by the line ``small is
1277 beautiful.''@footnote{Nicely printed parts are good PR for us, so do
1278 us a favor, and leave the tagline if you can.}
1279
1280 Normally, the @code{\header} is put at the top of the file. However,
1281 for a document that contains multiple pieces (e.g. an etude book, or
1282 an orchestral part with multiple movements), the header can be
1283 put in the @code{\score} block as follows; in this case, the name of
1284 each piece will be printed before each movement:
1285
1286
1287 @cindex Engraved by LilyPond
1288 @cindex signature line
1289 @cindex tag line
1290
1291 @example 
1292   \header @{
1293     title = "Eight miniatures" 
1294     composer = "Igor Stravinsky"
1295     tagline = "small is beautiful"
1296   @}
1297   
1298   \score @{ @dots{}
1299     \header @{ piece = "Adagio" @}
1300   @}
1301   \score @{ @dots{}
1302     \header @{ piece = "Menuetto" @}
1303   @}
1304 @end example
1305
1306 More information on titling can be found in @ref{Invoking lilypond}.
1307
1308
1309 @node Single staff polyphony
1310 @section Single staff polyphony
1311
1312 @cindex polyphony
1313 @cindex multiple voices
1314 @cindex voices, more -- on a staff
1315
1316 When different melodic lines are combined on a single staff they are
1317 printed as polyphonic voices: each voice has its own stems, slurs and
1318 beams, and the top voice has the stems up, while the bottom voice has
1319 them down.
1320
1321 Entering such parts is done by entering each voice as a sequence (with
1322 @code{@{ .. @}}), and combining those simultaneously, separating the
1323 voices with @code{\\}:
1324
1325 @example
1326   << @{ a4 g2 f4~ f4 @} \\
1327     @{ r4 g4 f2 f4 @} >>
1328 @end example
1329 @lilypond[relative=1]
1330 \new Staff << { a4 g2 f4~ f4 } \\
1331     { r4 g4 f2 f4 } >>
1332 @end lilypond
1333
1334 For polyphonic music typesetting, spacer rests can also be convenient: these
1335 are rests that do not print.  It is useful for filling up voices that
1336 temporarily do not play:
1337 @example
1338   << @{ a4 g2 f4~ f4 @} \\
1339     @{ s4 g4 f2 f4 @} >>
1340 @end example
1341 @lilypond[relative=1]
1342 \new Staff  << { a4 g2 f4~ f4 } \\
1343     { s4 g4 f2 f4 } >>
1344 @end lilypond
1345
1346 Again, these expressions can be nested arbitrarily:
1347
1348 @lilypond[fragment]
1349 <<
1350  \new Staff 
1351   \relative c''
1352     << { a4 g2 f4~ f4 } \\
1353       { s4 g4 f2 f4 } >>
1354  \new Staff 
1355   <<  { \clef bass <c g>1 ~ <c g>4   } \\
1356      { f4 d e2  ~ e4}
1357   >>
1358 >>
1359 @end lilypond
1360
1361
1362 More features of polyphonic typesetting are in the notation manual
1363 in @ref{Polyphony}.
1364
1365 @node Piano staves
1366 @section Piano staves
1367
1368 @cindex staff switch, manual
1369 @cindex cross staff voice, manual
1370 @cindex @code{\context}
1371
1372 Piano music is always typeset in two staves connected by a brace.
1373 Printing such a staff is similar to the polyphonic example in
1374 @ref{More staves}:
1375 @example
1376  << \new Staff @{ @dots{} @}
1377    \new Staff @{ @dots{} @}
1378  >>
1379 @end example
1380 but now this entire expression must be interpreted as a
1381 @code{PianoStaff}:
1382 @example
1383  \new PianoStaff << \new Staff @dots{} >>
1384 @end example
1385
1386 Here is a full-fledged example:
1387
1388 @lilypond[relative,fragment]
1389 \new PianoStaff
1390  << \new Staff { \time 2/4
1391      c4 c g' g  }
1392    \new Staff {
1393      \clef bass c,, c' e c }
1394  >>
1395 @end lilypond
1396
1397 More information on formatting piano music is in @ref{Piano music}. 
1398
1399 @node Organizing larger pieces
1400 @section Organizing larger pieces
1401
1402 When all of the elements discussed earlier are combined to produce
1403 larger files, the @code{\score} blocks get a lot bigger, because the
1404 music expressions are longer, and, in the case of polyphonic and/or
1405 orchestral pieces, more deeply nested. Such large expressions can
1406 become unwieldy.
1407
1408 By using variables, also known as identifiers, it is possible to break
1409 up complex music expressions.  An identifier is assigned as follows:
1410 @c
1411 @example
1412   namedMusic = \notes @{ @dots{}
1413 @end example
1414
1415 The contents of the music expression @code{namedMusic}, can be used
1416 later by preceding the name with a backslash, i.e. @code{\namedMusic}.
1417 In the next example, a two note motive is repeated two times by using
1418 variable substitution:
1419
1420 @lilypond[raggedright,verbatim]
1421 seufzer = \notes {
1422   dis'8 e'8
1423 }
1424 \score { \notes {
1425   \seufzer \seufzer 
1426 } }
1427 @end lilypond
1428
1429 The name of an identifier should have alphabetic characters only;
1430 no numbers, underscores or dashes. The assignment should be outside of
1431 the @code{\score} block.
1432
1433 It is possible to use variables for many other types of objects in the
1434 input.  For example,
1435 @example
1436   width = 4.5\cm
1437   name = "Wendy"
1438   aFivePaper = \paper @{ paperheight = 21.0 \cm @}
1439 @end example
1440 Depending on its contents, the identifier can be used in different
1441 places. The following example uses the above variables:
1442 @example
1443   \score @{
1444     \notes @{ c4^\name @}
1445     \paper @{
1446       \aFivePaper
1447       linewidth = \width
1448     @}
1449   @}
1450 @end example
1451
1452 More information on the possible uses of identifiers is in the
1453 technical manual, in TODO.
1454
1455
1456 @node An orchestral part
1457 @section An orchestral part
1458
1459 In orchestral music, all notes are printed twice: both in a part for
1460 the musicians, and in a full score for the conductor. Identifiers can
1461 be used to avoid double work: the music is entered once, and stored in
1462 a variable. The contents of that variable is then used to generate
1463 both the part and the score.
1464
1465 It is convenient  to define the notes in a  special file, for example,
1466 suppose that the @file{horn-music.ly} contains the following part of a
1467 horn/bassoon duo.
1468 @example
1469 hornNotes = \notes \relative c @{
1470   \time 2/4
1471   r4 f8 a cis4 f e d
1472 @}
1473 @end example
1474
1475 Then, an individual part is made by putting the following in a file:
1476 @example
1477 \include "horn-music.lyinc"
1478 \header @{
1479   instrument = "Horn in F"
1480 @}
1481 \score @{
1482   \notes \transpose f c' \hornNotes
1483 @}
1484 @end example
1485 The @code{\include} command substitutes the contents of the file at
1486 this position in the file, so that @code{hornNotes} is defined
1487 afterwards.  The code @code{\transpose f c'} indicates that the
1488 argument, being @code{\hornNotes}, should be transposed by a fifth
1489 downwards: sounding @code{f} is denoted by notated @code{c'}, which
1490 corresponds with tuning of a normal French Horn in F. The
1491 transposition can be seen in the following output:
1492
1493 @lilypond[raggedright]
1494 \score {
1495   \notes \transpose f c' \notes \relative c {
1496   \time 2/4
1497   r4 f8 a cis4 f e d
1498 }
1499 }
1500 @end lilypond
1501
1502 In ensemble pieces, one of the voices often does not play for many
1503 measures. This is denoted by a special rest, the multi-measure
1504 rest. It is entered with a capital R followed by a duration (1
1505 for a whole note, 2 for a half note, etc.) By multiplying the
1506 duration, longer rests can be constructed. For example, this rest
1507 takes 3 measures in 2/4 time:
1508 @example
1509   R2*3
1510 @end example
1511
1512 When printing the part, the following @code{skipBars} property must be
1513 set to true, to prevent the rest from being expanded to three one bar
1514 rests:
1515 @example
1516   \set Score.skipBars = ##t
1517 @end example
1518 Prepending the rest and the property setting above, leads to the
1519 following result:
1520
1521 @lilypond[raggedright]
1522 \score {\notes { \transpose f c' \relative c { \time 2/4
1523 \set Score.skipBars = ##t 
1524         R2*3
1525     r4 f8 a cis4 f e d } }}
1526 @end lilypond
1527
1528 The score is made by combining all of the music in a @code{\score}
1529 block, assuming that the other voice is in @code{bassoonNotes}, in the
1530 file @file{bassoon-music.ly}:
1531 @example
1532 \include "bassoon-music.lyinc"
1533 \include "horn-music.lyinc"
1534
1535 \score @{
1536   \simultaneous @{
1537     \new Staff \hornNotes
1538     \new Staff \bassoonNotes
1539   @} @}
1540 @end example
1541
1542 This would lead to the simple score depicted below:
1543
1544 @lilypond[raggedright]
1545 \score {
1546   \notes \relative c \simultaneous {
1547     \new Staff { \time 2/4
1548         R2*3
1549     r4 f8 a cis4 f e d }
1550     \new Staff { \clef bass
1551       r4 d,8 f | gis4 c |  b bes |
1552       a8 e f4 |  g d | gis f }
1553   } }
1554 @end lilypond 
1555
1556 More in-depth information on preparing parts and scores is in the
1557 notation manual, in @ref{Orchestral music}.
1558
1559
1560 @node Integrating text and music
1561 @section Integrating text and music
1562
1563 @cindex La@TeX{}, music in
1564 @cindex HTML, music in
1565 @cindex Texinfo, music in
1566
1567 Sometimes you might want to use music examples in a text that you are
1568 writing (for example, a musicological treatise, a songbook, or (like us)
1569 the LilyPond manual).  You can make such texts by hand, simply by
1570 importing a PostScript figure into your word processor.  However,
1571 there is an automated procedure to reduce the amount of work.
1572
1573 If you use HTML, La@TeX{}, or Texinfo, you can mix text and LilyPond
1574 code.  A script called @code{lilypond-book} will extract the music
1575 fragments, run LilyPond on them, and put back the resulting notation.
1576 This program is fully described in @ref{lilypond-book manual}.  Here
1577 we show a small example. The example also contains explanatory text,
1578 so we will not comment on it further:
1579
1580 @example
1581 \documentclass[a4paper]@{article@}
1582 \begin@{document@}
1583
1584 In a lilypond-book document, you can freely mix music and text. For
1585 example:
1586 \begin@{lilypond@}
1587   \score @{ \notes \relative c' @{
1588      c2 g'2 \times 2/3 @{ f8 e d @} c'2 g4
1589   @} @}
1590 \end@{lilypond@}
1591
1592 If you have no \verb+\score+ block in the fragment,
1593 \texttt@{lilypond-book@} will supply one:
1594
1595 \begin@{lilypond@}
1596   c'4
1597 \end@{lilypond@}
1598
1599 In the example you see here two things happened: a
1600 \verb+\score+ block was added, and the line width was set to natural
1601 length. You can specify  options by putting them in brackets:
1602
1603 \begin[staffsize=26,verbatim]@{lilypond@}
1604   c'4 f16
1605 \end@{lilypond@}
1606
1607 If you want to include large examples in the text it is more
1608 convenient to put it in a separate file:
1609
1610 \lilypondfile@{screech-boink.ly@}
1611
1612 \end@{document@}
1613 @end example
1614
1615 Under Unix, you can view the results as follows:
1616 @example
1617 $ cd input/tutorial
1618 $ mkdir -p out/
1619 $ lilypond-book --output=out/ lilybook.tex
1620 lilypond-book (GNU LilyPond) 2.1.19
1621 Reading `input/tutorial/lilybook.tex'
1622 Reading `input/screech-boink.ly'
1623 @var{lots of stuff deleted}
1624 Writing `out/lilybook.latex'
1625 $ cd out
1626 $ latex lilybook.latex
1627 @var{lots of stuff deleted}
1628 $ xdvi lilybook 
1629 @end example
1630
1631 To convert the file into a nice PDF document, run the following
1632 commands:
1633 @example
1634 $ dvips -Ppdf -u +lilypond lilybook
1635 $ ps2pdf lilybook.ps
1636 @end example
1637
1638
1639 Running lilypond-book and running latex creates a lot of temporary
1640 files.  You would not want those to clutter up your working
1641 directory.  The @code{outdir} option to lilypond-book creates the
1642 temporary files in a separate subdirectory @file{out}.
1643
1644 The result looks more or less like this: 
1645
1646 @separate
1647
1648 In a lilypond-book document, you can freely mix music and text. For
1649 example:
1650 @lilypond
1651 \score {
1652   \notes \relative c' {
1653     c2 g'2 \times 2/3 { f8 e d } c'2 g4
1654   }
1655   \paper {
1656     raggedright = ##t
1657   }
1658 }
1659 @end lilypond
1660
1661 If you have no @code{\score} block in the fragment,
1662 @code{lilypond-book} will supply one:
1663
1664 @lilypond
1665   c'4
1666 @end lilypond
1667
1668 In the example you see here, two things happened: a
1669 @code{score} block was added, and the line width was set to natural
1670 length.  You can specify options by putting them in brackets:
1671
1672 @lilypond[staffsize=26,verbatim]
1673   c'4 f16
1674 @end lilypond
1675
1676 If you want to include large examples in the text, it is more
1677 convenient to put it in a separate file:
1678
1679 @lilypondfile{screech-boink.ly}