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