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