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