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