* Documentation/user/music-glossary.tely (Top): remove 13pt.
[lilypond.git] / Documentation / user / tutorial.itely
blob02659ce3f9f402e801601038ee50ab5aa7aae3ec
1 @c -*-texinfo-*-
3 @c TODO:
4 @c   * more details about running lilypond; error messages,
5 @c     compiling/viewing (emacs?)
6 @c   * where to go from  First steps+More basics?
8 @node Tutorial
9 @chapter Tutorial
11 @html
12 <!--- @@WEB-TITLE@@=Tutorial --->
13 @end html
16 Using LilyPond comes down to encoding music in an input file. After
17 entering the music, the program is run on the file producing output
18 which can be viewed or printed.  In this tutorial, we will show step
19 by step how to enter such files, by showing fragments of input and the
20 corresponding output.  At the end of every section, a paragraph will
21 list where to find further information on the topics discussed.
23 Many people learn programs by trying and fiddling around with the
24 program.  This is also possible with LilyPond. If you click on a
25 picture in the HTML version of this manual, you will see the exact
26 LilyPond input that was used to generate that image.
27 @ifhtml
28 For example, consider the following input:
29 @c TODO: intertext fixme
30 @lilypond[relative 1,singleline,verbatim,intertext="with the following output:"]
31   c'^\markup { \bold \huge { Click on this image! } }
32 @end lilypond
34 @end ifhtml
35 By cutting and pasting the full input into a test file, you have a
36 starting template for experiments. If you like learning in this way,
37 you will probably want to print out or bookmark
38 @ifhtml
39 the
40 @end ifhtml
41 @ref{Cheat sheet}, which is a table listing all commands for quick
42 reference.
45 This tutorial starts with a short introduction to the LilyPond music
46 language.  After this first contact, we will show you how to to
47 produce printed output, normally using the program @code{ly2dvi}.  You
48 should then be able to create and print your first sheets of music.
50 @menu
51 * First steps::                 Music language of LilyPond.
52 * Running LilyPond::            Printing music.
53 * More about pitches and accidentals::  
54 * Octave entry::                
55 * Relative octave entry::       
56 * Combining music into compound expressions::  
57 * Adding articulation marks to notes::  
58 * Combining notes into chords::  
59 * Printing lyrics::             
60 * A lead sheet::                
61 * Listening to output::         
62 * Titling::                     
63 * Single staff polyphony::      
64 * Piano staffs::                
65 * Setting variables::           
66 * Fine tuning layout::          
67 * Organizing larger pieces::    
68 * An orchestral part::          
69 * Integrating text and music::  Integrating text and music.
70 @end menu
73 @node First steps
74 @section First steps
76 We start off by showing how very simple music is entered in LilyPond:
77 you get a note simply by typing its note name, from @samp{a}
78 through @samp{g}.  So if you enter
80 @example
81 c d e f g a b
82 @end example
84 @noindent
85 then the result looks like this:
87 @c ?
88 @c \transpose c c' { c d e f g a b }
89 @c @lily pond[notime]
90 @c \property Score.timing = ##f
91 @lilypond[notime, relative=2]
92 c d e f g a b
93 @end lilypond
95 The length of a note is specified by adding a number, @samp{1} for a
96 @rglos{whole note}, @samp{2} for a @rglos{half note}, and so on:
98 @example
99 a1 a2 a4 a16 a32
100 @end example
102 @lilypond[notime]
103 \property Score.timing = ##f
104 \property Staff.autoBeaming = ##f
105 \transpose c c' { a1 a2 a4 a16 a32 s16_" " }
106 @end lilypond
108 If you do not specify a @rglos{duration}, the previous one is used: 
110 @example
111 a4 a a2 a
112 @end example
114 @lilypond[notime]
115 \property Score.timing = ##f
116 \transpose c c' { a a a2 a s16_" " }
117 @end lilypond
120 Rests are entered just like notes, but with the name ``@code{r}'':
122 @cindex rests
123 @quotation
124 @example
125 r2 r4 r8 r16
126 @end example
128 @lilypond[fragment]
129 \property Score.timing = ##f
130 \property Staff.Clef = \turnOff
131 \property Staff.TimeSignature = \turnOff
132 r2 r4 r8 r16
133 s16_" "
134 @end lilypond
135 @end quotation
136 @separate
139 Add a dot @samp{.} after the duration to get a @rglos{dotted note}:
141 @example
142 a2. a4 a8. a16
143 @end example
145 @lilypond[notime]
146 \property Score.timing = ##f
147 \transpose c c' { a2. a4 a8. a16 s16_" " }
148 @end lilypond
151 The @rglos{meter} (or @rglos{time signature}) can be set with the
152 @code{\time} command:
154 @example
155 \time 3/4
156 \time 6/8
157 \time 4/4
158 @end example
160 @c a clef here may lead to confusion
161 @lilypond
162 \property Staff.Clef \set #'transparent = ##t 
163 \time 3/4
164 s4_" "
165 \time 6/8
166 s4_" "
167 \time 4/4
168 s16_" "
169 @end lilypond
172 The @rglos{clef} can be set using the @code{\clef} command:
174 @c what is more common name treble or violin?
175 @c in Dutch, its violin.
176 @c in English its definitely treble.
177 @example
178 \clef treble
179 \clef bass
180 \clef alto
181 \clef tenor
182 @end example
184 @lilypond[notime]
185 \property Score.timing = ##f
186 \clef violin
187 s4_" "
188 \clef bass
189 s4_" "
190 \clef alto
191 s4_" "
192 \clef tenor
193 s16_" "
194 @end lilypond
196 Notes and commands like @code{\clef} and @code{\time} , are enclosed
197 in @code{\notes @{@dots{}@}}.  This indicates that music (as opposed
198 to @rglos{lyrics}) follows:
200 @example
201 \notes @{
202   \time 3/4
203   \clef bass
204   c2 e4 g2.
205   f4 e d c2 r4
207 @end example
208 Now the piece of music is almost ready to be printed.  The final step is to
209 combine the music with a printing command.
211 The printing command is the so-called @code{\paper} block.  The
212 @code{\paper} block is used to customize printing specifics, but we
213 accept the defaults for now.  The music and the @code{\paper} block
214 are combined by enclosing them in @code{\score @{ ... @}}.  The
215 following is a complete and valid input file.
217 @example
218 \score @{
219   \notes @{
220     \time 3/4
221     \clef bass
222     c2 e4 g2.
223     f4 e d c2 r4
224   @}
225   \paper @{ @}
227 @end example
229 @lilypond[noindent]
230 \score {
231   \notes {
232      \time 3/4
233      \clef bass
234      c2 e4 g2.
235      f4 e d c2 r4
236   }
237   \paper {
238     linewidth = 55 * \staffspace
239   }
241 @end lilypond
243 During the rest of the tutorial, we will often leave out @code{\score}
244 and @code{\paper}, for clarity. However, both must be present when
245 feeding the file to LilyPond.
247 More elaborate information on entering pitches and durations is in
248 @ref{Pitches} and @ref{Durations}.  Clefs are fully explained in
249 @ref{Clef}.  Time signatures and other timing commands are described
250 in @ref{Time signature}.
253 @node Running LilyPond
254 @section Running LilyPond
256 In the last section we explained what kind of things you could enter
257 in a LilyPond file.  In this section we explain what commands to run
258 and how to view or print the output.  If you have not used LilyPond
259 before, want to test your setup, or want to run an example file
260 yourself, read this section.  The instructions that follow are for
261 Unix-like systems.  Some additional instructions for Microsoft Windows
262 are given at the end of this section.
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, then refer to the file @file{INSTALL.txt}}.  In
269 your text editor, enter the following input and save the file as
270 @file{test.ly}:
272 @quotation
273 @example
274 \score @{
275   \notes @{ c'4 e' g' @}
276 @} 
277 @end example
278 @end quotation
280 @cindex ly2dvi
282 @c now this is weird, running ly2dvi to run LilyPond
283 @c (therefore name change proposal) 
285 LilyPond is the program that computes the sheet music. All other
286 things, such as adding titles, page breaking and other page layout,
287 are done by a small wrapper program called
288 @code{ly2dvi}. @code{ly2dvi} calls LilyPond to render the music, and
289 then adds the titling and page layout instructions.  To process
290 @file{test.ly} with @code{ly2dvi}, proceed as follows:
292 @quotation
293 @example
294 ly2dvi -p test.ly
295 @end example
296 @end quotation
298 You will see something resembling:
300 @quotation
301 @example
302 GNU LilyPond 1.8.0
303 Now processing: `/home/fred/ly/test.ly'
304 Parsing...
305 Interpreting music...[1]
306  @emph{ ... more interesting stuff ... }
307 PDF output to `test.pdf'...
308 DVI output to `test.dvi'...
309 @end example
310 @end quotation
311 @cindex DVI file
312 @cindex Viewing music
313 @cindex xdvi
315 The result of the ly2dvi is the file @file{test.pdf}.@footnote{ For
316 @TeX{} afficionados, there is also a (@file{test.dvi}) file. It can be
317 viewed with @code{xdvi}. The DVI uses a lot of PostScript specials,
318 which do not show up in the magnifying glass. The specials also mean
319 that the DVI file cannot be processed with @code{dvilj}. Use
320 @code{dvips} for printing.
321 @cindex dvips
322 @cindex dvilj
323 @cindex DVI driver
324 }  One of the following commands should put the PDF on your
325 screen:
326 @c eeek
327 @quotation
328 @example
329   gv test.pdf
330   ghostview test.pdf
331   ggv test.pdf
332   kghostview test.pdf
333   xpdf test.pdf
334   gpdf test.pdf
335   acroread test.pdf
336 @end example
337 @end quotation
338 If the music on your screen looks good, you can print it by clicking
339 File/Print inside your viewing program.
341 @cindex Ghostscript
342 @cindex @code{lpr}
343 @cindex Printing output
344 @cindex PostScript
345 @cindex PDF
348 On Windows,  the terminal is started by clicking on the LilyPond or
349 Cygwin icon.  Any text editor (such as NotePad, Emacs or Vim) may be
350 used to edit the LilyPond file.  If you have a PDF viewer installed,
351 use that for viewing the PDF
352 @c where on file system for double-click people?
353 If you have no viewer, then  you can download @code{GSView}  from
354 @uref{http://www.cs.wisc.edu/~ghost}. With @code{GSView},
355 the PDF file can viewed with
356 @quotation
357 @example
358 @code{gsview32 test.pdf}
359 @end example
360 @end quotation
361 Printing may be done with
362 @quotation
363 @example
364 @code{gsview32 /s test.pdf}
365 @end example
366 @end quotation
368 The commands for formatting and printing music are detailed in
369 @ref{Invoking LilyPond}.
371 @node More about pitches and accidentals
372 @section More about pitches and accidentals
374 A @rglos{sharp} (@texisharp{}) is made by adding @samp{is}, a
375 @rglos{flat} (@texiflat{}) by adding @samp{es}.  As you might expect,
376 a @rglos{double sharp} or @rglos{double flat} is made by adding
377 @samp{isis} or @samp{eses}:@footnote{This syntax derived from note
378 naming conventions in Nordic and Germanic languages, like German and
379 Dutch.}
381 @example
382 cis1 ees fisis aeses
383 @end example
385 @lilypond[notime]
386 \property Score.timing = ##f
387 \transpose c c' { cis1 ees fisis aeses s16_" " }
388 @end lilypond
391 @cindex key signature, setting
393 The key signature is set with the command ``@code{\key}'', followed by
394 a pitch and  @code{\major} or @code{\minor}:
395 @quotation
396 @example
397 \key d \major
399 \key c \minor
401 @end example
403 @lilypond[fragment]
404 \property Staff.TimeSignature = \turnOff
405 \key d \major
407 \key c \minor
409 @end lilypond
410 @end quotation
413 @cindex tie
414 A tie is created by adding a tilde ``@code{~}'' to the first note
415 being tied:
416 @quotation
417 @lilypond[fragment,verbatim,relative 2]
418 g4-~ g a2-~ a4
419 @end lilypond
420 @end quotation
421 @separate
423 This example shows the key signature, accidentals and ties in action:
425 @quotation
426 @example
427 \score @{
428   \notes @{
429     \time 4/4
430     \key g \minor
431     \clef violin
432     r4 r8 a8 gis4 b
433     g8 d4.-~ d' e'8
434     fis4 fis8 fis8 eis4  a8 gis-~
435     gis2 r2
436   @}
437   \paper @{ @}
439 @end example
441 @lilypond
442 \score {
443   \notes { \transpose c c' { 
444     \time 4/4
445     \key g \minor
446     \clef violin
447     r4 r8 a8 gis4 b
448     g8 d4.-~ d e8
449     fis4 fis8 fis8 eis4  a8 gis-~
450     gis2 r2
451   }}
452   \paper { linewidth = #(* 50 staffspace) }
454 @end lilypond
455 @end quotation
456 @cindex accidentals
458 There are some interesting points to note in this example.  Bar lines
459 and beams are drawn automatically.  Line breaks are calculated
460 automatically; it does not matter where the lines breaks are in the
461 source file. Finally, the order of time, key and clef changes is not
462 relevant: in the printout, these are ordered according to standard
463 notation conventions.
465 Accidentals (sharps and flats) do not have to be marked explicitly:
466 you just enter the pitch of the note, and an accidental is printed
467 only when necessary. The flip side of this mechanism, is that you have
468 to mark notes as sharp or flat, even when they do not get accidentals.
469 For example, in this example:
470 @lilypond[fragment]
471 \clef bass
472 \property Staff.TimeSignature = #'()
473 \key cis \major
474 cis dis eis fis gis ais bis 
475 @end lilypond
476 no note gets an explicit accidental, but still you enter
477 @example
478 \clef bass
479 \key cis \major
480 cis dis eis fis gis ais bis 
481 @end example
483 Adding all alterations explicitly might require some more effort when
484 typing, but the advantage is that transposing is easier. It also makes
485 it possible to use different conventions for when to print
486 accidentals.
488 @node  Octave entry
489 @section Octave entry
492 @c Tim wants to move this quotes example just before the: quotes-do not-work
493 @c score, but we'd need to remove quotes from the other two (key and
494 @c tie) examples...
496 @c better to have this just before the `octaves are bad' snipped
497 @c but we'd need to remove the ', from \key and tie 
498 To raise a note by an octave, add a high quote @code{'} (apostrophe) to
499 the note name, to lower a note one octave, add a ``low quote'' @code{,}
500 (a comma).  Middle C is @code{c'}:
502 @quotation
503 @example
504 c'4 c'' c''' \clef bass c c,
505 @end example
507 @lilypond[fragment]
508 \property Score.timing = ##f
509 \property Staff.TimeSignature = \turnOff
510 c'4 c'' c''' \clef bass c c,
511 @end lilypond
512 @end quotation
513 @separate
515 An example of the use of quotes is in the following Mozart fragment:
516 @lilypond[singleline,fragment,verbatim]
517   \key a \major
518   \time 6/8
519   cis''8. d''16 cis''8 e''4 e''8
520   b'8. cis''16 b'8 d''4 d''8 
521 @end lilypond 
523 This example shows that music in a high register needs lots of quotes.
524 This makes the input less readable, and it is a source of errors.  The
525 solution is to use ``relative octave'' mode.  In practice, this is the
526 most convenient way to copy existing music.  To use relative mode, add
527 @code{\relative} before the piece of music.  You must also give a note
528 from which relative starts, in this case @code{c''}.  If you do not
529 use octavation quotes (i.e. do not add ' or , after a note), relative
530 mode chooses the note that is closest to the previous one.
531 For example, @code{c f} goes up while @code{c g} goes down:
533 @quotation
534 @example
535 \relative c'' @{
536   c f c g c
538 @end example
540 @lilypond[fragment]
541 \property Score.timing = ##f
542 \property Staff.TimeSignature = \turnOff
543 \relative c'' {
544   c f c g c
546 @end lilypond
547 @end quotation
548 @separate
551 Since most music has small intervals, in relative mode pieces can be
552 written almost without using octavation quotes.  In relative mode, the
553 Mozart example is entered as
555 @lilypond[singleline,fragment,verbatim]
556 \relative c'' {
557   \key a \major
558   \time 6/8
559   cis8. d16 cis8 e4 e8
560   b8. cis16 b8 d4 d8
562 @end lilypond 
565 @c needed better, maybe even redundant explanation
566 @c   added another example below.
567 @c grappig: Pa vond het heel logies, en slim toen-i eenmaal begreep.
568 @c in eerste instantie drong het `relative' niet door zonder extra uitleg.
569 Larger intervals are made by adding octavation quotes.  Quotes or
570 commas do not determine the absolute height of a note; the height of a
571 note is relative to the previous one.
572 @c do not use commas or quotes in this sentence
573 For example: @code{c f,} goes down; @code{f, f} are both the same;
574 @code{c' c} are the same; and @code{c g'} goes up:
576 @quotation
577 @example
578 \relative c'' @{
579   c f, f c' c g' c,
581 @end example
583 @lilypond[fragment]
584 \property Score.timing = ##f
585 \property Staff.TimeSignature = \turnOff
586 \relative c'' {
587   c f, f c' c g' c,
589 @end lilypond
590 @end quotation
591 @separate
594 Here is an example of the difference between relative mode and
595 ``normal'' (non-relative) mode:
597 @quotation
598 @example
599 \relative a @{
600 \clef bass
601   a d a e d c' d'
603 @end example
605 @lilypond[fragment]
606 \property Score.timing = ##f
607 \property Staff.TimeSignature = \turnOff
608 \relative a {
609 \clef bass
610   a d a e d c' d'
612 @end lilypond
613 @end quotation
614 @separate
616 @quotation
617 @example
618 \clef bass
619   a d a e d c' d'
620 @end example
622 @lilypond[fragment]
623 \property Score.timing = ##f
624 \property Staff.TimeSignature = \turnOff
625 \clef bass
626   a d a e d c' d'
627 @end lilypond
628 @end quotation
629 @separate
634 @node  Relative octave entry
635 @section Relative octave entry
637 @c lousy example
638 @c ? --hwn
639 @c fragment of 1st hrn in Adams' The Chairman Dances, with creative
640 @c chromatic thing pasted in front.  (admittedly the original does not
641 @c have a phrasing slur. The problem is that we do not want the slur
642 @c and the Phrasing slur to collide. We are trying to make a good
643 @c impression here.
645 @quotation
646 @lilypond[fragment,relative 1, verbatim]
647 a8-(-\( ais b  c-) cis2 b'2 a4 cis,  c-\)
648 @end lilypond
649 @end quotation
650 @separate
652 @cindex beams, by hand 
653 Beams are drawn automatically, but if you do not like where they are
654 put, they can be entered by hand. Mark the first note to be beamed
655 with @code{[} and the last one with @code{]}:
656 @quotation
657 @lilypond[fragment,relative 1, verbatim]
658 a8-[ ais-] d-[ es r d-]
659 @end lilypond
660 @end quotation
661 @separate
663 Rests are described in full detail in @ref{Rests}. 
665 The notation manual discusses ties in @ref{Ties}.
670 @node Combining music into compound expressions
671 @section Combining music into compound expressions
673 To print more than one staff, each piece of music that makes up a
674 staff is marked by adding @code{\context Staff} before it.  These
675 @code{Staff}'s are then grouped inside @code{\simultaneous @{} and
676 @code{@}}, as is demonstrated here:
678 @quotation
679 @lilypond[fragment,verbatim]
680 \simultaneous {
681   \context Staff = staffA { \clef violin c'' }
682   \context Staff = staffB { \clef bass c }
684 @end lilypond
685 @end quotation
688 In this example, @code{\simultaneous } indicates that both music
689 fragments happen at the same time, and must be printed stacked
690 vertically.  The notation @code{< .. >} can also be used as a
691 shorthand for @code{\simultaneous @{ .. @}}.
693 @code{\context} introduces a ``notation context''.  To understand this
694 concept, imagine that you are performing a piece of music. When you
695 perform the music, you combine the symbols printed at a certain point
696 with contextual information. For example, without knowing the current
697 clef, and the accidentals in the last measure, it would be impossible
698 to determine the pitch of a note. In other words, this information
699 forms context that helps you decipher a score. LilyPond produces
700 notation from music, so in effect, it does the inverse of reading
701 scores. Therefore, it also needs to keep track of contextual
702 information. This information is maintained in ``notation contexts.''
703 There are several types of contexts, e.g. @code{Staff}, @code{Voice}
704 and @code{Score}, but also @code{Lyrics} and
705 @code{ChordNames}. Prepending @code{\context} to a chunk of music
706 indicates what kind of context to use for interpreting it.
708 By specifying different names (in this case @code{staffA} and
709 @code{staffB}), two different contexts are created, leading to two
710 staves. It does not matter which names they are given, as long as they
711 are different. If they get the same name, the chunks of music are
712 assumed to belong on the same staff, and will be printed like that.
714 @separate
716 We can now typeset a melody with two staves:
718 @quotation
719 @lilypond[verbatim,singleline]
720 \score {
721   \notes 
722   < \context Staff = staffA {
723       \time 3/4
724       \clef violin
725       \relative c'' {
726         e2-( d4 c2 b4 a8-[ a-]
727         b-[ b-] g-[ g-] a2.-) }  
728     }
729     \context Staff = staffB {
730        \clef bass
731        c2 e4  g2.
732        f4 e d c2.
733     }
734   >
735   \paper {} 
737 @end lilypond
738 @end quotation
740 The example shows how small chunks of music, for example, the notes
741 @code{c2}, @code{e4}, etc. of the second staff, are combined to form a
742 larger chunk by enclosing it in braces. Again, a larger chunk is
743 formed by prefix @code{\context Staff} to it, and that chunk is
744 combined with @code{< >}. This mechanism is similar with mathematical
745 formulas: in a formula, a so-called expression is formed by combining
746 simpler expressions into larger expressions. For example, 
748 @quotation
749   1
751   1 + 2
752   
753   (1 + 2) * 3
754   
755   ((1 + 2) * 3) / (4 * 5)
756 @end quotation
757 @cindex expression
758 @cindex music expression
759 is a sequence of expressions, where each expression is contained in
760 the next one.  The simplest expressions are numbers and operators
761 (like +, * and /). Parentheses are used to group expressions.  In
762 LilyPond input, a similar mechanism is used. Here, the simplest
763 expressions are notes and rests.  By enclosing expressions in @code{<
764 >} and @code{@{ @}}, more complex music is formed. The @code{\context}
765 also forms new expressions; prepending it to a music expression yields
766 a new expression.
768 Like mathematical expressions, music expressions can be nested
769 arbitrarily deep, e.g.
770 @lilypond[verbatim,relative 1] 
771   { c <c e>
772       < { e f } { c <b d> }
773       >
774   }
775 @end lilypond 
778 @cindex indent
779 When spreading expressions over multiple lines, it is customary to use
780 an indent that indicates the nesting level. Formatting music like this
781 eases reading, and helps you  insert the right amount of closing
782 braces at the end of an expression. For example,
783 @example
784 \score @{
785   \notes <
786     @{
787       @dots{}
788     @}
789     @{
790       @dots{}
791     @}
792   >
794 @end example
799 @node Adding articulation marks to notes
800 @section Adding articulation marks to notes
802 @cindex articulation
803 @cindex accents
804 @cindex staccato
806 Common accents can be added to a note using a dash (`@code{-}') and a
807 single character:
808 @quotation
809 @lilypond[verbatim,relative 1]
810 c-. c-- c-> c-^ c-+ c-_
811 @end lilypond
812 @end quotation
813 @separate
815 @cindex fingering
816 Similarly, fingering indications can be added to a note using a dash
817 (`@code{-}') and the digit to be printed:
819 @lilypond[verbatim,relative 1]
820   c-3 e-5 b-2 a-1
821 @end lilypond
824 Dynamic signs are made by adding the markings to the note:
825 @quotation
826 @lilypond[verbatim,relative 1]
827 c-\ff c-\mf
828 @end lilypond
829 @end quotation
830 @separate
832 @cindex dynamics
833 @cindex decrescendo
834 @cindex crescendo
836 Crescendi and decrescendi are started with the commands @code{\<} and
837 @code{\>}. The command @code{\!} finishes a crescendo on the note it
838 is attached to:
839 @quotation
840 @lilypond[verbatim,relative 1]
841 c2-\<  c2-\!-\ff  c2-\>  c2-\!
842 @end lilypond
843 @end quotation
844 @separate
848 @cindex slur
850 A slur is drawn across many notes, and indicates bound articulation
851 (legato).  The starting note and ending note are marked with a
852 ``@code{(}'' and a ``@code{)}'' respectively:
854 @quotation
855 @lilypond[fragment,relative 1, verbatim]
856 d4-( c16-)-( cis d e c cis d e-)-( d4-)
857 @end lilypond
858 @end quotation
859 @separate
860 @cindex slurs versus ties
861 A slur is different from a tie. A tie simply makes the first note
862 sound longer, and can only be used on pairs of notes with the same
863 pitch. Slurs indicate the articulations of notes, and can be used on
864 larger groups of notes. Slurs and ties are also nested in practice:
865 @lilypond[fragment, relative=1]
866 c2-~-( c8 fis fis4 ~ fis2 g2-)
867 @end lilypond
869 @cindex phrasing slurs
870 If you need two slurs at the same time (one for articulation, one for
871 phrasing), you can also make a phrasing slur with @code{\(} and
872 @code{\)}.
874 More information on fingering, articulation, slurs, phrasing slurs,
875 and dynamics can be found in @ref{Fingering instructions},
876 @ref{Articulations}, @ref{Slurs}, @ref{Phrasing slurs}, and @ref{Dynamics},
877 respectively.
879 @node Combining notes into chords
880 @section Combining notes into chords
882 @cindex chords
883 Chords can be made by
884 surrounding pitches with @code{<<} and @code{>}>:
885 @quotation
886 @lilypond[relative 0, fragment,verbatim]
887 r4 <<c e g>>4 <<c f a>>8
888 @end lilypond
889 @end quotation
890 @separate
893 You can combine beams and ties with chords.  Beam and tie markings
894 must be placed outside the chord markers:
895 @quotation
896 @lilypond[relative 0, fragment,verbatim]
897 r4 <<c e g>>8-[ <<c f a>>-]-~ <<c f a>>
898 @end lilypond
899 @end quotation
901 @quotation
902 @example
903 r4 <<c e g>>8-\>-( <<c e g>> <<c e g>>  <<c f a>>8-\!-)
904 @end example
905 @lilypond[relative 0, fragment]
906 \slurUp
907 r4 <<c e g>>8-\>-( <<c e g>> <<c e g>>  <<c f a>>8-\!-)
908 @end lilypond
909 @end quotation
910 @separate
914 @menu
915 * Basic rhythmical commands::   
916 * Commenting input files::      
917 @end menu
919 @node Basic rhythmical commands
920 @subsection  Basic rhythmical commands
922 @cindex pickup
923 @cindex anacruse
924 @cindex upstep
925 @cindex partial measure
926 A pickup (or upstep) is entered with the keyword @code{\partial}. It
927 is followed by a duration: @code{\partial 4} is a quarter note upstep
928 and @code{\partial 8} an eighth note:
929 @lilypond[relative 1,verbatim,fragment]
930   \partial 8
931   f8 c2 d e
932 @end lilypond
934 @cindex tuplets
935 @cindex triplets
936 Tuplets are made with the @code{\times} keyword.  It takes two
937 arguments: a fraction and a piece of music.  The duration of the piece
938 of music is multiplied by the fraction.  Triplets make notes occupy
939 2/3 of their notated duration, so  a triplet has  2/3 as its fraction:
941 @lilypond[relative 0,verbatim,fragment]
942   \times 2/3 { f8 g a }
943   \times 2/3 { c r c }
944 @end lilypond 
946 @cindex grace notes
947 @cindex accacciatura
948 Grace notes are also made by prefixing a note, or a set of notes with
949 a keyword. In this case, the keyword is @code{\grace}:
950 @lilypond[relative 1, verbatim,fragment]
951   c4 \grace b16-( c4-)
952   \grace { d16-( e } d4-)
953 @end lilypond
955 @noindent
956 More information on grace notes, tuplets and upsteps are in @ref{Grace
957 notes}, @ref{Tuplets} and @ref{Partial measures}.
961 @node Commenting input files
962 @subsection Commenting input files
964 @cindex comments
965 @cindex line comment
966 @cindex block comment
967 Comments are pieces of the input that are ignored.  There are two
968 types of comments. A line comments is introduced by @code{%}: after
969 that, the rest of that line is ignored.  Block comments span larger
970 sections of input.  Anything that is enclosed in @code{%@{} and
971 @code{%@}} is ignored too. The following fragment shows possible uses
972 for comments:
974 @example
975   % notes for twinkle twinkle follow:
976   c4 c   g' g  a a
977   
978   %@{
979   
980     This line, and the notes below
981     are ignored, since they are in a
982     block comment.
984     g g f f e e d d c2 
985   %@}
986 @end example
991 @node Printing lyrics
992 @section Printing lyrics
993 @cindex lyrics
995 @cindex Lyrics
996 @cindex Songs
997 Lyrics are entered by separating each syllable with a space, and
998 surrounding them with @code{\lyrics @{ @dots{} @}}, for example,
999 @example
1000   \lyrics @{ I want to break free @}
1001 @end example
1003 Like notes, lyrics are also a form of music, but they must not be
1004 printed on a staff, which is the default way to print music. To print
1005 them as lyrics, they must be marked with @code{ \context Lyrics}:
1006 @example
1007   \context Lyrics  \lyrics @{ I want to break free @}
1008 @end example
1009 The melody for this song is as follows:
1011 @lilypond[fragment,relative=1]
1012    \partial 8
1013      c8
1014    \times 2/3 {  f4 g g } \times 2/3 { g4-( a2-) }
1015 @end lilypond
1017 The lyrics can be set to these notes, combining both with the
1018 @code{\addlyrics} keyword:
1019 @example
1020  \addlyrics
1021     \notes @{ @dots{} @}
1022     \context Lyrics @dots{}
1023 @end example
1025 The final result is 
1026 @lilypond[verbatim,linewidth=6.0cm]
1027 \score  {
1028  \notes {
1029   \addlyrics
1030    \relative c' {
1031      \partial 8
1032      c8
1033      \times 2/3 { f g g } \times 2/3 { g4-( a2-) }
1034    }
1035    \context Lyrics  \lyrics { I want to break free }
1037  \paper{ }
1039 @end lilypond
1041 @cindex melisma
1042 @cindex extender line
1043 @c synonyms?
1044 This melody ends on a @rglos{melisma}, a single syllable (``free'')
1045 sung to more than one note. This is indicated with a @emph{extender
1046 line}. It is entered as two underscores, i.e.
1047 @example
1048   \lyrics @{ I want to break free __ @}
1049 @end example 
1050 @lilypond[]
1051 \score  {
1052  \notes {
1053   \addlyrics
1054    \relative c' {
1055    \partial 8
1056      c8
1057      \times 2/3 { f g g } \times 2/3 { g4-( a2-) }
1059      %% ugh, this is to deal with bugs in the extender implementation
1060      \hideNotes
1061      c32
1062    }
1063    \context Lyrics  \lyrics { I want to break free __ }
1065  \paper{ linewidth = 9.0 \cm }
1067 @end lilypond
1069 Similarly, hyphens between words can be entered as two dashes,
1070 resulting in a centered hyphen between two syllables:
1071 @example
1072   Twin -- kle twin -- kle
1073 @end example
1074 @lilypond[singleline]
1075 \score {
1076   \addlyrics \notes \relative f' { \time 2/4
1077     f4 f c' c' }
1078     \context Lyrics \lyrics { Twin -- kle twin -- kle
1080 \paper { linewidth = 6.0 \cm }
1083 @end lilypond
1085 More options, like putting multiple lines of lyrics below a melody are
1086 discussed in @ref{Vocal music}.
1090 @node A lead sheet
1091 @section A lead sheet
1093 @cindex Lead sheets
1094 @cindex chords
1095 @cindex chord names
1097 In popular music, it is common to denote accompaniment as chord-names.
1098 Using them in LilyPond has two parts, just like lyrics: entering the
1099 chords (with @code{\chords}), and printing them (with @code{\context
1100 ChordNames}).
1102 Chord names are entered by starting chords mode (with @code{\chords}).
1103 In chords mode, you can enter chords with a letter (indicating the
1104 root of the chord), and a durations following that:
1106 @lilypond[verbatim]
1107   \chords { c2 f4. g8 } 
1108 @end lilypond
1110 @noindent
1111 The result of @code{\chords} is a list of chords, and is  equivalent
1112 to entering chords with @code{<<@dots{}>>}.
1114 Other chords can be created by adding modifiers, after a colon.  The
1115 following example shows a few common modifiers:
1117 @lilypond[verbatim]
1118   \chords { c2 f4:m g4:maj7 gis1:dim7 }
1119 @end lilypond
1121 Printing chords is done by adding @code{\context ChordNames}
1122 before the chords thus entered:
1124 @lilypond[verbatim]
1125  \context ChordNames \chords \chords { c2 f4.:m g4.:maj7 gis8:dim7 }
1126 @end lilypond
1128 @cindex lead sheet 
1129 When put together,  chord names, lyrics and a melody form
1130 a lead sheet, for example,
1132 @example
1133 \score @{
1134   <
1135     \context ChordNames \chords @{ @emph{chords} @}
1136     \addlyrics
1137       \notes @emph{the melody}
1138       \context Lyrics \lyrics @{ @emph{the text} @}
1139   >
1140   \paper @{ @}
1142 @end example
1143 @lilypond[]
1144 \score  {
1145   < 
1146    \context ChordNames \chords { r8 c2:sus4 f } 
1147    \addlyrics
1148     \notes \relative c' {
1149      \partial 8
1150      c8
1151      \times 2/3 { f g g } \times 2/3 { g4-( a2-) } }
1152    \context Lyrics  \lyrics { I want to break free __ }
1153   >
1154  \paper{ raggedright = ##t }
1156 @end lilypond
1159 A complete list of modifiers, and other options for layout are in the
1160 reference manual section @ref{Chords}.
1162 @node Listening to output
1163 @section Listening to output
1165 @cindex sound
1166 @cindex MIDI
1168 MIDI (Musical Instrument Digital Interface) is a standard for
1169 connecting and recording digital instruments.  A MIDI file is like a
1170 tape recording of a MIDI instrument. The @code{\midi} block makes the
1171 music go to a MIDI file, so you can listen to the music you entered.
1172 It is great for checking the music: octaves that are off, or
1173 accidentals that were mistyped, stand out very much when listening to
1174 the musical transcription.
1176 @code{\midi} can be used in similarly to @code{\paper @{ @}}, for
1177 example
1178 @example 
1179 \score @{
1180     @var{..music..}
1181     \midi  @{ \tempo 4=72 @}
1182     \paper  @{ @}
1184 @end example 
1186 Here, the tempo is specified using the @code{\tempo} command.  In this
1187 case the tempo of quarter notes is set to 72 beats per minute. More
1188 information on auditory output is in the @ref{Sound} section in the
1189 notation manual.
1193 @node Titling
1194 @section Titling
1196 Bibliographic information is entered in a separate block, the
1197 @code{\header} block. The name of the piece, its composer, etc. are
1198 entered as assignment, within @code{\header @{ @dots{} @}}. For
1199 example,
1200 @example 
1201   \header @{
1202     title = "Eight miniatures" 
1203     composer = "Igor Stravinsky"
1204     tagline = "small is beautiful"
1205   @}
1206   
1207   \score @{ @dots{} @}
1208 @end example
1210 @cindex bibliographic information
1211 @cindex titles
1212 @cindex composer
1213 @cindex ly2dvi
1216 When the file is processed by @code{ly2dvi}, the title and composer
1217 specified are printed above the music. The `tagline' is a short line
1218 printed at bottom of the last page, which normally says ``Lily was
1219 here, version @dots{}''. In the example above, it is replaced by the
1220 line ``small is beautiful''.
1222 Normally, the @code{\header} is put at the top of the file. However,
1223 for a document that contains multiple pieces (e.g. a etude book, or
1224 part with multiple movements), then the header can be put into the
1225 @code{\score} block as follows; in this case, the name of each piece
1226 will be printed before each movement:
1229 @cindex Lily was here
1230 @cindex signature line
1231 @cindex tag line
1233 @example 
1234   \header @{
1235     title = "Eight miniatures" 
1236     composer = "Igor Stravinsky"
1237     tagline = "small is beautiful"
1238   @}
1239   
1240   \score @{ @dots{}
1241     \header @{ piece = "Adagio" @}
1242   @}
1243   \score @{ @dots{}
1244     \header @{ piece = "Menuetto" @}
1245   @}
1246 @end example
1248 More information on titling can be found in @ref{Invoking ly2dvi}.
1251 @node Single staff polyphony
1252 @section Single staff polyphony
1254 @cindex polyphony
1255 @cindex multiple voices
1256 @cindex voices, more -- on a staff
1258 When different melodic lines are combined on a single staff, these are
1259 printed as polyphonic voices: each voice has its own stems, slurs
1260 and beams, and the top voice has the stems up, while the bottom voice
1261 has stems down.
1263 Entering such parts is done by entering each voice as a sequence (with
1264 @code{@{ .. @}}), and combining those simultaneously, separating the
1265 voices with @code{\\}:
1267 @example
1268   < @{ a4 g2 f4-~ f4 @} \\
1269     @{ r4 g4 f2 f4 @} >
1270 @end example
1271 @lilypond[relative 1]
1272 \context Staff   < { a4 g2 f4-~ f4 } \\
1273     { r4 g4 f2 f4 } >
1274 @end lilypond
1276 For polyphonic music typesetting, spacer rests can also be convenient: these
1277 are rests that do not print.  It is useful for filling up voices that
1278 temporarily do not play:
1279 @example
1280   < @{ a4 g2 f4-~ f4 @} \\
1281     @{ s4 g4 f2 f4 @} >
1282 @end example
1283 @lilypond[relative 1]
1284 \context Staff  < { a4 g2 f4-~ f4 } \\
1285     { s4 g4 f2 f4 } >
1286 @end lilypond
1288 Again, these expressions can be nested arbitrarily:
1290 @lilypond[fragment]
1292  \context Staff = staffA 
1293   \relative c''
1294     < { a4 g2 f4-~ f4 } \\
1295       { s4 g4 f2 f4 } >
1296  \context Staff = staffB 
1297   <  { \clef bass <<c g>>1  } \\
1298      { f4 d e2 }
1299   >
1301 @end lilypond
1304 More features of polyphonic typesetting are in the notation manual
1305 in @ref{Polyphony}.
1307 @node Piano staffs
1308 @section Piano staffs
1310 @cindex staff switch, manual
1311 @cindex cross staff voice, manual
1312 @cindex @code{\translator}
1314 Piano music is always typeset in two staffs connected by a brace.
1315 Printing such a staff is done similar to the polyphonic example in
1316 @ref{Combining music into compound expressions}:
1317 @example
1318  < \context Staff = up @{ @dots{} @}
1319    \context Staff = down @{ @dots{} @}
1321 @end example
1322 but now this entire expression must be interpreted as a
1323 @code{PianoStaff}:
1324 @example
1325  \context PianoStaff < \context Staff @dots{} >
1326 @end example
1328 Here is a full-fledged example:
1330 @lilypond[relative 0,fragment]
1331 \context PianoStaff
1332  < \context Staff = up { \time 2/4
1333      c4 c g' g  }
1334    \context Staff = down {
1335      \clef bass c,, c' e c }
1337 @end lilypond
1339 More information on formatting piano music is in @ref{Piano music}. 
1341 @node Setting variables
1342 @section Setting variables
1344 When the music is converted from notes to print, it is interpreted
1345 from left-to-right order, similar to what happens when we read
1346 music. During this step, context-sensitive information, such as the
1347 accidentals to print, and where barlines must be placed, are stored in
1348 variables. These variables are called @emph{translation properties}.
1349 The properties can also be manipulated from input files. Consider this input:
1350 @example
1351 \property Staff.autoBeaming = ##f
1352 @end example 
1353 It sets the property named @code{autoBeaming} in the current staff to
1354 @code{##f}, which means `false'. This property controls whether beams
1355 are printed automatically:
1356 @lilypond[relative 1,fragment,verbatim]
1357   c8 c c c
1358   \property Staff.autoBeaming = ##f
1359   c8 c c c  
1360 @end lilypond
1362 @noindent
1363 LilyPond includes a built-in programming language, namely, a dialect
1364 of Scheme.  The argument to @code{\property}, @code{##f}, is an
1365 expression in that language.  The first hash-mark signals that a piece
1366 of Scheme code follows. The second hash character is part of the
1367 boolean value true (@code{#t}).  Values of other types may be
1368 entered as follows:
1369 @itemize @bullet
1370 @item a string, enclosed in double quotes, for example,
1371 @example
1372   \property Staff.instrument = #"French Horn"
1373 @end example
1374 @item a boolean: either @code{#t} or @code{#f}, for true and false
1375 respectively, e.g.
1376 @example
1377   \property Voice.autoBeaming = ##f
1378   \property Score.skipBars = ##t
1379 @end example
1381 @item a number, such as
1382 @example
1383   \property Score.currentBarNumber = #20
1384 @end example
1386 @item a symbol, which is introduced by a quote character, as in 
1387 @example
1388   \property Staff.crescendoSpanner = #'dashed-line
1389 @end example
1391 @item a pair, which is also introduced by a quote character, like in
1392 the following statements, which set properties to the pairs (-7.5, 6) 
1393 and (3, 4) respectively:
1395 @example
1396   \property Staff.minimumVerticalExtent  = #'(-7.5 . 6)
1397   \property Staff.timeSignatureFraction  = #'(3 . 4)
1398 @end example
1401 @end itemize
1403 There are many different properties, and not all of them are listed in
1404 this manual. However, the internal documentation lists them all in the
1405 @internalsref{All translation properties}, and most properties
1406 are demonstrated in one of the
1407 @ifhtml
1408 @uref{../../../input/test/out-www/collated-files.html,tips-and-tricks}
1409 @end ifhtml
1410 @ifnothtml
1411 tips-and-tricks
1412 @end ifnothtml
1413 examples.
1416 @node Fine tuning layout
1417 @section Fine tuning layout
1419 Sometimes it is necessary to change music layout by hand.  When music
1420 is formatted, layout objects are created for each symbol.  For
1421 example, every clef and every note head is represented by a layout
1422 object.  These layout objects also carry variables, which we call
1423 @emph{layout properties}. By changing these variables from their
1424 values, we can alter the look of a formatted score:
1426 @lilypond[verbatim,relative 0]
1427   c4
1428   \property Voice.Stem \override #'thickness = #3.0
1429   c4 c4 c4 
1430 @end lilypond
1432 @noindent
1433 In the example shown here, the layout property @code{thickness} (a
1434 symbol) is set to 3 in the @code{Stem} layout objects of the current
1435 Voice.  As a result, the notes following @code{\property} have thicker
1436 stems.
1438 In most cases of manual overrides, only a single object must be
1439 changed. This can be achieved by prefixing @code{\once} to the
1440 @code{\property} statement, i.e.
1442 @example
1443  \once \property Voice.Stem \set #'thickness = #3.0
1444 @end example
1446 @lilypond[relative 0]
1447   c4
1448   \once \property Voice.Stem \set #'thickness = #3.0
1449   c4 c4 c4 
1450 @end lilypond
1452 @noindent
1453 Some overrides are so common that predefined commands are provided as
1454 a short cut.  For example, @code{\slurUp} and @code{\stemDown}. These
1455 commands are described in
1456 @ifhtml
1458 @end ifhtml
1459 @ref{Notation manual}, under the sections for slurs and stems
1460 respectively.
1462 The exact tuning possibilities for each type of layout object are
1463 documented in the internal documentation of the respective
1464 object. However, many layout objects share properties, which can be
1465 used to apply generic tweaks.  We mention a couple of these:
1467 @itemize @bullet
1468 @cindex @code{extra-offset}
1469 @item The @code{extra-offset} property, which
1470 has a pair of numbers as value, moves around objects in the printout.
1471 The first number controls left-right movement; a positive number will
1472 move the object to the right.  The second number controls up-down
1473 movement; a positive number will move it higher.  The unit of these
1474 offsets are staff-spaces.  The @code{extra-offset} property is a
1475 low-level feature: the formatting engine is completely oblivious to
1476 these offsets.
1478 In the following example example, the second fingering is moved a
1479 little to the left, and 1.8 staff space downwards:
1481 @cindex setting object properties
1483 @lilypond[relative 1,verbatim]
1484 \stemUp
1486 \once \property Voice.Fingering
1487   \set #'extra-offset = #'(-0.3 . -1.8) 
1489 @end lilypond
1491 @item
1492 Setting the @code{transparent} property will make an object be printed
1493 in `invisible ink': the object is not printed, but all its other
1494 behavior is retained. The object still takes space, it takes part in
1495 collisions, and slurs, ties and beams can be attached to it.
1497 @cindex transparent objects
1498 @cindex removing objects
1499 @cindex invisible objects
1500 The following example demonstrates how to connect different voices
1501 using ties. Normally ties only happen between notes of the same
1502 voice. By introducing a tie in a different voice, and blanking a stem
1503 in that voice, the tie appears to cross voices:
1505 @lilypond[fragment,relative 1,verbatim]
1506 \context Staff < {
1507       \once \property Voice.Stem \set #'transparent = ##t
1508       b8~ b8
1509   } \\ {
1510        b-[ g8-]
1511   } >
1512 @end lilypond
1514 @item
1515 The @code{padding} property for objects with
1516 @code{side-position-interface} can be set to increase distance between
1517 symbols that are printed above or below notes. We only give an
1518 example; a more elaborate explanation is in @ref{Constructing a
1519 tweak}:
1521 @lilypond[relative 1]
1522   c2-\fermata
1523   \property Voice.Script \set #'padding = #3
1524   b2-\fermata
1525 @end lilypond
1527 @end itemize
1529 More specific overrides are also possible.  The notation manual
1530 discusses in depth how to figure out these statements for yourself, in
1531 @ref{Tuning output}.
1533 @node Organizing larger pieces
1534 @section Organizing larger pieces
1536 When all of the elements discussed earlier are combined to produce
1537 larger files, the @code{\score} blocks get a lot bigger, because the
1538 music expressions are longer, and, in the case of polyphonic and/or
1539 orchestral pieces, more deeply nested.
1541 By using variables, also known as identifiers, it is possible to break
1542 up complex music expressions.
1543 An identifier is assigned as follows:
1544 @example
1545   namedMusic = \notes @{ @dots{}
1546 @end example
1548 The contents of the music expression @code{namedMusic}, can be used
1549 later by preceding the name with a backslash, i.e. @code{\namedMusic}.
1550 In the next example, a two note motive is repeated thrice by using
1551 variable substitution:
1553 @lilypond[singleline,verbatim]
1554 seufzer  = \notes {
1555   dis'8 e'8
1557 \score { \notes {
1558   \seufzer \seufzer \seufzer
1559 } }
1560 @end lilypond
1562 The name of an identifier should only have alphabetic characters only,
1563 and no numbers, underscores or dashes. The assignment should be
1564 outside of the @code{\score} block.
1566 It is possible to use variables for many other types of objects in the
1567 input.  For example,
1568 @example
1569   width = 4.5\cm
1570   name = "Wendy"
1571   aFivePaper = \paper @{ paperheight = 21.0 \cm @}
1572 @end example
1573 Depending on its contents, the identifier can be used in different
1574 places. The following example uses the above variables:
1575 @example
1576   \score @{
1577     \notes @{ c4^\name @}
1578     \paper @{
1579       \aFivePaper
1580       linewidth = \width
1581     @}
1582   @}
1583 @end example
1585 More information on the possible uses of identifiers is in the
1586 technical manual, in @ref{Scheme datatypes}.
1589 @node An orchestral part
1590 @section An orchestral part
1592 In orchestral music, all notes are printed twice: both in a part for
1593 the musicians, and in a full score for the conductor. Identifiers can
1594 be used to avoid double work: the music is entered once, and stored in
1595 variable. The contents of that variable is then used to generate
1596 both the part and the score.
1598 It is convenient  to define the notes in a  special file, for example,
1599 suppose that the @file{horn-music.ly} contains the following part of a
1600 horn/bassoon duo.
1601 @example
1602 hornNotes = \notes \relative c @{
1603   \time 2/4
1604   r4 f8 a cis4 f e d
1606 @end example
1608 Then, an individual part is made by putting the following in a file:
1609 @example
1610 \include "horn-music.ly"
1611 \header @{
1612   instrument = "Horn in F"
1614 \score @{
1615   \notes \transpose c' f \hornNotes
1617 @end example
1618 The @code{\include} command substitutes the contents of the file at
1619 this position in the file, so that @code{hornNotes} is defined
1620 afterwards.  Since the horn is tuned in F, the @code{\transpose}
1621 command is used. The code @code{\transpose c' f} indicates that the
1622 argument, being @code{\hornNotes}, should be transposed by a fifth
1623 downwards: the @code{c'} becomes a @code{f}. The transposition can be
1624 seen in the following output:
1626 @lilypond[singleline]
1627 \score {
1628   \notes \transpose c' f  \notes \relative c' {
1629   \time 2/4
1630   r4 f8 a cis4 f e d
1633 @end lilypond
1635 In ensemble pieces, one of the voices often does not play for many
1636 measures. This is denoted by a special rest, the multi-measure
1637 rest. It is entered with a capital R, and followed by a duration (1
1638 for a whole note, 2 for a half note, etc.) By multiplying the
1639 duration, longer rests can be constructed. For example, the next rest
1640 takes 3 measures in 2/4 time:
1641 @example
1642   R2*3
1643 @end example
1645 When printing the part, the following @code{skipBars} property must be
1646 set to false, to prevent the rest from being expanded in three one bar
1647 rests:
1648 @example
1649   \property Score.skipBars = ##t
1650 @end example
1651 Prepending the rest and the property setting above, leads to the
1652 following result:
1654 @lilypond[singleline]
1655 \score {\notes { \transpose c' f \relative c' { \time 2/4
1656 \property Score.skipBars = ##t 
1657         R2*3
1658     r4 f8 a cis4 f e d } }}
1659 @end lilypond
1661 The score is made by combining all of the music in a @code{\score}
1662 block, assuming that the other voice is in @code{bassoonNotes}, in the
1663 file @file{bassoon-music.ly}:
1664 @example
1665 \include "bassoon-music.ly"
1666 \include "horn-music.ly"
1668 \score @{
1669   \simultaneous @{
1670     \context Staff = hornStaff \hornNotes
1671     \context Staff = bsnStaff \bassoonNotes
1672   @} @}
1673 @end example
1675 This would lead to the simple score depicted below:
1677 @lilypond[singleline]
1678 \score {
1679   \notes \relative c \simultaneous {
1680     \context Staff = hornStaff { \time 2/4
1681         R2*3
1682     r4 f8 a cis4 f e d }
1683     \context Staff = fagStaff { \clef bass
1684       r4 d,8 f | gis4 c |  b bes |
1685       a8 e f4 |  g d | gis f }
1686   } }
1687 @end lilypond 
1689 More in-depth information on preparing parts and scores is in the
1690 notation manual, in @ref{Orchestral music}.
1693 @node Integrating text and music
1694 @section Integrating text and music
1696 @cindex La@TeX{}, music in
1697 @cindex HTML, music in
1698 @cindex Texinfo, music in
1700 Sometimes you might want to use music examples in a text that you are
1701 writing (for example, a musicological treatise, a songbook, or (like us)
1702 the LilyPond manual).  You can make such texts by hand, simply by
1703 importing a PostScript figure into your word processor.  However,
1704 there is an automated procedure to reduce the amount of work.
1706 If you use HTML, La@TeX{}, or Texinfo, you can mix text and LilyPond
1707 code.  A script called @code{lilypond-book} will extract the music
1708 fragments, run LilyPond on them, and put back the resulting notation.
1709 This program is fully described in @ref{lilypond-book manual}.  Here
1710 we show a small example;  since the example contains also explanatory
1711 text, we will not comment it further:
1713 @example
1714 \documentclass[a4paper]@{article@}
1715 \begin@{document@}
1717 In a lilypond-book document, you can freely mix music and text. For
1718 example:
1719 \begin@{lilypond@}
1720   \score @{ \notes \relative c' @{
1721      c2 g'2 \times 2/3 @{ f8 e d @} c'2 g4
1722   @} @}
1723 \end@{lilypond@}
1725 Notice that the music line length matches the margin settings of the
1726 document.
1728 If you have no \verb+\score+ block in the fragment,
1729 \texttt@{lilypond-book@} will supply one:
1731 \begin@{lilypond@}
1732   c'4
1733 \end@{lilypond@}
1735 In the example you see here, two things happened: a
1736 \verb+\score+ block was added, and the line width was set to natural
1737 length. You can specify  options by putting them in brackets:
1739 \begin[26pt,verbatim]@{lilypond@}
1740   c'4 f16
1741 \end@{lilypond@}
1743 If you want to include large examples into the text, it is more
1744 convenient to put it in a separate file:
1746 \lilypondfile@{screech-boink.ly@}
1748 \end@{document@}
1749 @end example
1751 Under Unix, you can view the results as follows:
1752 @example
1753 $ cd input/tutorial
1754 $ mkdir -p out/
1755 $ lilypond-book --outdir=out/ lilbook.tex
1756 lilypond-book (GNU LilyPond) 1.7.23
1757 Reading `input/tutorial/lilbook.tex'
1758 Reading `input/screech-boink6.ly'
1759 @var{lots of stuff deleted}
1760 Writing `out/lilbook.latex'
1761 $ cd out
1762 $ latex lilbook.latex
1763 @var{lots of stuff deleted}
1764 $ xdvi lilbook 
1765 @end example
1767 Running lilypond-book and running latex creates a lot of temporary
1768 files, and you would not want those to clutter up your working
1769 directory.  The @code{outdir} option to lilypond-book creates the
1770 temporary files in a separate subdirectory @file{out}.
1772 The result looks more or less like this: 
1774 @separate
1776 In a lilypond-book document, you can freely mix music and text. For
1777 example:
1778 @lilypond
1779 \score {
1780   \notes \relative c' {
1781     c2 g'2 \times 2/3 { f8 e d } c'2 g4
1782   }
1783   \paper {
1784     raggedright = ##t
1785   }
1787 @end lilypond
1789 Notice that the music line length matches the margin settings of the
1790 document.
1792 If you have no @code{\score} block in the fragment,
1793 @code{lilypond-book} will supply one:
1795 @lilypond
1796   c'4
1797 @end lilypond
1799 In the example you see here, two things happened: a
1800 @code{score} block was added, and the line width was set to natural
1801 length. You can specify  options by putting them in brackets:
1803 @lilypond[26pt,verbatim]
1804   c'4 f16
1805 @end lilypond
1807 If you want to include large examples into the text, it is more
1808 convenient to put it in a separate file:
1810 @lilypondfile{screech-boink.ly}