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