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