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