]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/notation/staff.itely
d097535643b0bb9a4f6e6841755b11c07b65fa5c
[lilypond.git] / Documentation / notation / staff.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @ignore
3     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
4
5     When revising a translation, copy the HEAD committish of the
6     version that you are working on.  For details, see the Contributors'
7     Guide, node Updating translation committishes..
8 @end ignore
9
10 @c \version "2.19.21"
11
12 @node Staff notation
13 @section Staff notation
14
15 @c The line width is a bit of a hack to allow space for the
16 @c  instrument names.
17 @lilypondfile[quote,ragged-right,line-width=14.5\cm,staffsize=16]{staff-headword.ly}
18
19 This section explains how to influence the appearance of staves,
20 how to print scores with more than one staff, and how to add tempo
21 indications and cue notes to staves.
22
23 @menu
24 * Displaying staves::
25 * Modifying single staves::
26 * Writing parts::
27 @end menu
28
29
30 @node Displaying staves
31 @subsection Displaying staves
32
33 This section describes the different methods of creating and
34 grouping staves.
35
36 @menu
37 * Instantiating new staves::
38 * Grouping staves::
39 * Nested staff groups::
40 * Separating systems::
41 @end menu
42
43
44 @node Instantiating new staves
45 @unnumberedsubsubsec Instantiating new staves
46
47 @cindex new staff
48 @cindex staff initiation
49 @cindex staff instantiation
50 @cindex staff, new
51 @cindex staff, single
52 @cindex staff, drum
53 @cindex staff, percussion
54 @cindex drum staff
55 @cindex percussion staff
56 @cindex Gregorian transcription staff
57 @cindex rhythmic staff
58 @cindex tabstaff
59 @cindex tablature
60
61 @funindex \drummode
62 @funindex DrumStaff
63 @funindex RhythmicStaff
64 @funindex TabStaff
65 @funindex MensuralStaff
66 @funindex VaticanaStaff
67 @funindex GregorianTranscriptionStaff
68
69 @notation{Staves} (singular: @notation{staff}) are created with
70 the @code{\new} or @code{\context} commands.  For details, see
71 @ref{Creating and referencing contexts}.
72
73 The basic staff context is @code{Staff}:
74
75 @lilypond[verbatim,quote]
76 \new Staff \relative { c''4 d e f }
77 @end lilypond
78
79 The @code{DrumStaff} context creates a five-line staff set up for
80 a typical drum set.  Each instrument is shown with a different
81 symbol.  The instruments are entered in drum mode following a
82 @code{\drummode} command, with each instrument specified by name.
83 For details, see @ref{Percussion staves}.
84
85 @lilypond[verbatim,quote]
86 \new DrumStaff {
87   \drummode { cymc hh ss tomh }
88 }
89 @end lilypond
90
91 @code{RhythmicStaff} creates a single-line staff that only
92 displays the rhythmic values of the input.  Real durations are
93 preserved.  For details, see @ref{Showing melody rhythms}.
94
95 @lilypond[verbatim,quote]
96 \new RhythmicStaff { c4 d e f }
97 @end lilypond
98
99 @code{TabStaff} creates a tablature with six strings in standard
100 guitar tuning.  For details, see @ref{Default tablatures}.
101
102 @lilypond[verbatim,quote]
103 \new TabStaff \relative { c''4 d e f }
104 @end lilypond
105
106 There are two staff contexts specific for the notation of ancient
107 music: @code{MensuralStaff} and @code{VaticanaStaff}.  They are
108 described in @ref{Pre-defined contexts}.
109
110 The @code{GregorianTranscriptionStaff} context creates a staff to
111 notate modern Gregorian chant.  It does not show bar lines.
112
113 @lilypond[verbatim,quote]
114 \new GregorianTranscriptionStaff \relative { c''4 d e f e d }
115 @end lilypond
116
117 New single staff contexts may be defined.  For details, see
118 @ref{Defining new contexts}.
119
120 @seealso
121 Music Glossary:
122 @rglos{staff},
123 @rglos{staves}.
124
125 Notation Reference:
126 @ref{Creating and referencing contexts},
127 @ref{Percussion staves},
128 @ref{Showing melody rhythms},
129 @ref{Default tablatures},
130 @ref{Pre-defined contexts},
131 @ref{Staff symbol},
132 @ref{Gregorian chant contexts},
133 @ref{Mensural contexts},
134 @ref{Defining new contexts}.
135
136 Snippets:
137 @rlsr{Staff notation}.
138
139 Internals Reference:
140 @rinternals{Staff},
141 @rinternals{DrumStaff},
142 @rinternals{GregorianTranscriptionStaff},
143 @rinternals{RhythmicStaff},
144 @rinternals{TabStaff},
145 @rinternals{MensuralStaff},
146 @rinternals{VaticanaStaff},
147 @rinternals{StaffSymbol}.
148
149
150 @node Grouping staves
151 @unnumberedsubsubsec Grouping staves
152
153 @cindex start of system
154 @cindex staff, multiple
155 @cindex staves, multiple
156 @cindex system start delimiters
157 @cindex bracket, vertical
158 @cindex brace, vertical
159 @cindex choir staff
160 @cindex grand staff
161 @cindex piano staff
162 @cindex staff group
163 @cindex staff, choir
164 @cindex staff, piano
165 @cindex staff, grand
166 @cindex system
167
168 Various contexts exist to group single staves together in order to
169 form multi-stave systems.  Each grouping context sets the style of
170 the system start delimiter and the behavior of bar lines.
171
172 If no context is specified, the default properties will be used:
173 the group is started with a vertical line, and the bar lines are
174 not connected.
175
176 @lilypond[verbatim,quote]
177 <<
178   \new Staff \relative { c''1 c }
179   \new Staff \relative { c''1 c }
180 >>
181 @end lilypond
182
183 In the @code{StaffGroup} context, the group is started with a
184 bracket and bar lines are drawn through all the staves.
185
186 @lilypond[verbatim,quote]
187 \new StaffGroup <<
188   \new Staff \relative { c''1 c }
189   \new Staff \relative { c''1 c }
190 >>
191 @end lilypond
192
193 In a @code{ChoirStaff}, the group starts with a bracket, but bar
194 lines are not connected.
195
196 @lilypond[verbatim,quote]
197 \new ChoirStaff <<
198   \new Staff \relative { c''1 c }
199   \new Staff \relative { c''1 c }
200 >>
201 @end lilypond
202
203 In a @code{GrandStaff}, the group begins with a brace, and bar
204 lines are connected between the staves.
205
206 @lilypond[verbatim,quote]
207 \new GrandStaff <<
208   \new Staff \relative { c''1 c }
209   \new Staff \relative { c''1 c }
210 >>
211 @end lilypond
212
213 The @code{PianoStaff} is identical to a @code{GrandStaff}, except
214 that it supports printing the instrument name directly.  For
215 details, see @ref{Instrument names}.
216
217 @lilypond[verbatim,quote]
218 \new PianoStaff <<
219   \set PianoStaff.instrumentName = #"Piano"
220   \new Staff \relative { c''1 c }
221   \new Staff \relative { \clef bass c1 c }
222 >>
223 @end lilypond
224
225 Each staff group context sets the property
226 @code{systemStartDelimiter} to one of the following values:
227 @code{SystemStartBar}, @code{SystemStartBrace}, or
228 @code{SystemStartBracket}.  A fourth delimiter,
229 @code{SystemStartSquare}, is also available, but it must be
230 explicitly specified.
231
232 New staff group contexts may be defined.  For details, see
233 @ref{Defining new contexts}.
234
235
236 @snippets
237
238 @lilypondfile[verbatim,quote,texidoc,doctitle]
239 {use-square-bracket-at-the-start-of-a-staff-group.ly}
240
241 @lilypondfile[verbatim,quote,texidoc,doctitle]
242 {display-bracket-with-only-one-staff-in-a-system.ly}
243
244 @cindex mensurstriche layout
245 @cindex renaissance music
246 @cindex transcription of mensural music
247 @cindex mensural music, transcription of
248
249 @lilypondfile[verbatim,quote,texidoc,doctitle]
250 {mensurstriche-layout-bar-lines-between-the-staves.ly}
251
252 @seealso
253 Music Glossary:
254 @rglos{brace},
255 @rglos{bracket},
256 @rglos{grand staff}.
257
258 Notation Reference:
259 @ref{Instrument names},
260 @ref{Defining new contexts}.
261
262 Snippets:
263 @rlsr{Staff notation}.
264
265 Internals Reference:
266 @rinternals{Staff},
267 @rinternals{StaffGroup},
268 @rinternals{ChoirStaff},
269 @rinternals{GrandStaff},
270 @rinternals{PianoStaff},
271 @rinternals{SystemStartBar},
272 @rinternals{SystemStartBrace},
273 @rinternals{SystemStartBracket},
274 @rinternals{SystemStartSquare}.
275
276
277 @node Nested staff groups
278 @unnumberedsubsubsec Nested staff groups
279
280 @cindex staff, nested
281 @cindex staves, nested
282 @cindex nesting of staves
283 @cindex system start delimiters, nested
284 @cindex nested staff brackets
285 @cindex brackets, nesting of
286 @cindex braces, nesting of
287
288 Staff-group contexts can be nested to arbitrary depths.  In this
289 case, each child context creates a new bracket adjacent to the
290 bracket of its parent group.
291
292 @lilypond[verbatim,quote]
293 \new StaffGroup <<
294   \new Staff \relative { c''2 c | c2 c }
295   \new StaffGroup <<
296     \new Staff \relative { g'2 g | g2 g }
297     \new StaffGroup \with {
298       systemStartDelimiter = #'SystemStartSquare
299     }
300     <<
301       \new Staff \relative { e'2 e | e2 e }
302       \new Staff \relative { c'2 c | c2 c }
303     >>
304   >>
305 >>
306 @end lilypond
307
308 New nested staff group contexts can be defined.  For details, see
309 @ref{Defining new contexts}.
310
311
312 @snippets
313
314 @lilypondfile[verbatim,quote,texidoc,doctitle]
315 {nesting-staves.ly}
316
317 @seealso
318 Notation Reference:
319 @ref{Grouping staves},
320 @ref{Instrument names},
321 @ref{Defining new contexts}.
322
323 Snippets:
324 @rlsr{Staff notation}.
325
326 Internals Reference:
327 @rinternals{StaffGroup},
328 @rinternals{ChoirStaff},
329 @rinternals{SystemStartBar},
330 @rinternals{SystemStartBrace},
331 @rinternals{SystemStartBracket},
332 @rinternals{SystemStartSquare}.
333
334
335 @node Separating systems
336 @unnumberedsubsubsec Separating systems
337
338 @cindex system separator mark
339
340 If the number of systems per page changes from page to page it is
341 customary to separate the systems by placing a system separator mark
342 between them.  By default the system separator is blank, but can be
343 turned on with a @code{\paper} option.
344
345 @c \book is required here to display the system separator
346 @c ragged-right is required as there are two systems
347 @lilypond[verbatim,quote,ragged-right]
348 \book {
349   \score {
350     \new StaffGroup <<
351       \new Staff {
352         \relative {
353           c''4 c c c
354           \break
355           c4 c c c
356         }
357       }
358       \new Staff {
359         \relative {
360           c''4 c c c
361           \break
362           c4 c c c
363         }
364       }
365     >>
366   }
367   \paper {
368     system-separator-markup = \slashSeparator
369     % following commands are needed only to format this documentation
370     paper-width = 100\mm
371     paper-height = 100\mm
372     tagline = ##f
373   }
374 }
375 @end lilypond
376
377 @seealso
378 Notation Reference:
379 @ref{Page layout}.
380
381 Snippets:
382 @rlsr{Staff notation}.
383
384
385 @node Modifying single staves
386 @subsection Modifying single staves
387
388 This section explains how to change specific attributes of one
389 staff: for example, modifying the number of staff lines or the
390 staff size.  Methods to start and stop staves and set ossia
391 sections are also described.
392
393 @menu
394 * Staff symbol::
395 * Ossia staves::
396 * Hiding staves::
397 @end menu
398
399
400 @node Staff symbol
401 @unnumberedsubsubsec Staff symbol
402
403 @cindex staff symbol
404 @cindex staff lines, stopping and starting
405 @cindex staff lines, modifying
406 @cindex ledger lines
407 @cindex ledger lines, internal
408 @cindex ledger lines, modifying
409
410 @funindex \startStaff
411 @funindex \stopStaff
412
413 The @code{\stopStaff} and @code{\startStaff} commands can be used to
414 stop or (re)start the staff lines respectively, from being printed at
415 any point witin a score.
416
417 @lilypond[verbatim,quote]
418 \relative {
419   \stopStaff f''4 d \startStaff g, e
420   f'4 d \stopStaff g, e
421   f'4 d \startStaff g, e
422 }
423 @end lilypond
424
425 @predefined
426 @code{\startStaff},
427 @code{\stopStaff}.
428 @endpredefined
429
430 The lines of a staff belong to the @code{StaffSymbol} grob (including
431 ledger lines) and can be modified using @code{StaffSymbol} properties, but
432 these modifications must be made before the staff is (re)started.
433
434 The number of staff lines can be altered:
435
436 @lilypond[verbatim,quote]
437 \relative {
438   f''4 d \stopStaff
439   \override Staff.StaffSymbol.line-count = #2
440   \startStaff g, e |
441
442   f'4 d \stopStaff
443   \revert Staff.StaffSymbol.line-count
444   \startStaff g, e |
445 }
446 @end lilypond
447
448 The position of each staff line can also be altered.  A list of
449 numbers sets each line's position.  @code{0}@tie{}corresponds to the normal
450 center line, and the normal line positions are
451 @code{(-4@tie{}-2@tie{}0@tie{}2@tie{}4)}.  A single staff line is
452 printed for every value entered so that the number of staff lines, as
453 well as their position, can be changed with a single override.
454
455 @lilypond[verbatim,quote]
456 \relative {
457   f''4 d \stopStaff
458   \override Staff.StaffSymbol.line-positions = #'(1 3 5 -1 -3)
459   \startStaff g, e |
460   f'4 d \stopStaff
461   \override Staff.StaffSymbol.line-positions = #'(8 6.5 -6 -8 -0.5)
462   \startStaff g, e |
463 }
464 @end lilypond
465
466 To preserve typical stem directions (in the bottom half of the staff
467 stems point up, in the top half they point down), align the center
468 line (or space) of the customized staff with the position of the
469 normal center line (0).  The clef position and the position of
470 middle@tie{}C may need to be adjusted accordingly to fit the new
471 lines.  See @ref{Clef}.
472
473 Staff line thickness can be altered.  Ledger lines and note stems, by
474 default, are also affected.
475
476 @lilypond[verbatim,quote]
477 \new Staff \with {
478   \override StaffSymbol.thickness = #3
479 } \relative {
480   f''4 d g, e
481 }
482 @end lilypond
483
484 It is also possible to set ledger line thickness independently of staff
485 lines.
486
487 @lilypond[verbatim,quote]
488 \new Staff \with {
489   \override StaffSymbol.thickness = #2
490   \override StaffSymbol.ledger-line-thickness = #'(0.5 . 0.4)
491 } \relative {
492   f'''4 a, a,, f
493 }
494 @end lilypond
495
496 @noindent
497 The first value is multiplied by the staff line thickness, the second by
498 the staff space and then the two values are added together to give the
499 new thickness of the ledger line.
500
501 The vertical positions of ledger lines can be altered,
502
503 @lilypond[verbatim,quote]
504 \new Staff \with {
505   \override StaffSymbol.ledger-positions = #'(-3 -2 -1 2 5 6)
506 } \relative {
507   f'''4 a, a,, f
508 }
509 @end lilypond
510
511 Additional ledger lines can be made to appear above or below note heads
512 depending on the current position relative to other note heads that
513 also have their own ledger lines.
514
515 @lilypond[verbatim,quote]
516 \new Staff \with {
517   \override StaffSymbol.ledger-extra = #4
518 } \relative {
519   f'''4 a, d, f,
520 }
521 @end lilypond
522
523 Ledger lines can also be made to appear inside the staff where custom
524 staff lines are required.  The example shows the default position of
525 ledger lines when the explicit @code{ledger-position} is and is not set.
526 The @code{\stopStaff} is needed in the example to revert the
527 @code{\override} for the whole @code{StaffSymbol}.
528
529 @lilypond[verbatim,quote]
530 \relative d' {
531   \override Staff.StaffSymbol.line-positions = #'(-8 0 2 4)
532   d4 e f g
533   \stopStaff
534   \startStaff
535   \override Staff.StaffSymbol.ledger-positions = #'(-8 -6 (-4 -2) 0)
536   d4 e f g
537 }
538 @end lilypond
539
540 The distance between staff lines can be altered.  This affects ledger
541 line spacing as well.
542
543 @lilypond[verbatim,quote]
544 \new Staff \with {
545   \override StaffSymbol.staff-space = #1.5
546 } \relative {
547   f'''4 d, g, e,
548 }
549 @end lilypond
550
551 @snippets
552 @lilypondfile[verbatim,quote,texidoc,doctitle]
553 {making-some-staff-lines-thicker-than-the-others.ly}
554
555 @seealso
556 Music Glossary:
557 @rglos{line},
558 @rglos{ledger line},
559 @rglos{staff}.
560
561 Notation Reference:
562 @ref{Clef}.
563
564 Snippets:
565 @rlsr{Staff notation}.
566
567 Internals Reference:
568 @rinternals{StaffSymbol},
569 @rinternals{staff-symbol-interface}.
570
571
572 @node Ossia staves
573 @unnumberedsubsubsec Ossia staves
574
575 @cindex staff, Frenched
576 @cindex ossia
577 @cindex Frenched staves
578 @cindex staff, resizing of
579 @cindex resizing of staves
580
581 @funindex \startStaff
582 @funindex \stopStaff
583
584 @notation{Ossia} staves can be set by creating a new simultaneous
585 staff in the appropriate location:
586
587 @lilypond[verbatim,quote]
588 \new Staff \relative {
589   c''4 b d c
590   <<
591     { c4 b d c }
592     \new Staff { e4 d f e }
593   >>
594   c4 b c2
595 }
596 @end lilypond
597
598 @noindent
599 However, the above example is not what is usually desired.  To
600 create ossia staves that are above the original staff, have no
601 time signature or clef, and have a smaller font size, tweaks must
602 be used.  The Learning Manual describes a specific technique to
603 achieve this goal, beginning with
604 @rlearning{Nesting music expressions}.
605
606 The following example uses the @code{alignAboveContext} property
607 to align the ossia staff.  This method is most appropriate when
608 only a few ossia staves are needed.
609
610 @lilypond[verbatim,quote]
611 \new Staff = "main" \relative {
612   c''4 b d c
613   <<
614     { c4 b d c }
615
616     \new Staff \with {
617       \remove "Time_signature_engraver"
618       alignAboveContext = #"main"
619       \magnifyStaff #2/3
620       firstClef = ##f
621     }
622     { e4 d f e }
623   >>
624   c4 b c2
625 }
626 @end lilypond
627
628 If many isolated ossia staves are needed, creating an empty
629 @code{Staff} context with a specific @emph{context id} may be more
630 appropriate; the ossia staves may then be created by
631 @emph{calling} this context and using @code{\startStaff} and
632 @code{\stopStaff} at the desired locations.  The benefits of this
633 method are more apparent if the piece is longer than the following
634 example.
635
636 @lilypond[verbatim,quote,ragged-right]
637 <<
638   \new Staff = "ossia" \with {
639     \remove "Time_signature_engraver"
640     \hide Clef
641     \magnifyStaff #2/3
642   }
643   { \stopStaff s1*6 }
644
645   \new Staff \relative {
646     c'4 b c2
647     <<
648       { e4 f e2 }
649       \context Staff = "ossia" {
650         \startStaff e4 g8 f e2 \stopStaff
651       }
652     >>
653     g4 a g2 \break
654     c4 b c2
655     <<
656       { g4 a g2 }
657       \context Staff = "ossia" {
658         \startStaff g4 e8 f g2 \stopStaff
659       }
660     >>
661     e4 d c2
662   }
663 >>
664 @end lilypond
665
666
667 Using the @code{\RemoveAllEmptyStaves} command to create ossia
668 staves may be used as an alternative.  This method is most
669 convenient when ossia staves occur immediately following a line
670 break.  For more information about
671 @code{\RemoveAllEmptyStaves}, see @ref{Hiding staves}.
672
673 @lilypond[verbatim,quote,ragged-right]
674 <<
675   \new Staff = "ossia" \with {
676     \remove "Time_signature_engraver"
677     \hide Clef
678     \magnifyStaff #2/3
679     \RemoveAllEmptyStaves
680   } \relative {
681     R1*3
682     c''4 e8 d c2
683   }
684   \new Staff \relative {
685     c'4 b c2
686     e4 f e2
687     g4 a g2 \break
688     c4 b c2
689     g4 a g2
690     e4 d c2
691   }
692 >>
693 @end lilypond
694
695
696 @snippets
697
698 @lilypondfile[verbatim,quote,texidoc,doctitle]
699 {vertically-aligning-ossias-and-lyrics.ly}
700
701 @seealso
702 Music Glossary:
703 @rglos{ossia},
704 @rglos{staff},
705 @rglos{Frenched staff}.
706
707 Learning Manual:
708 @rlearning{Nesting music expressions},
709 @rlearning{Size of objects},
710 @rlearning{Length and thickness of objects}.
711
712 Notation Reference:
713 @ref{Hiding staves}.
714
715 Snippets:
716 @rlsr{Staff notation}.
717
718 Internals Reference:
719 @rinternals{StaffSymbol}.
720
721
722 @node Hiding staves
723 @unnumberedsubsubsec Hiding staves
724
725 @cindex Frenched score
726 @cindex Frenched staff
727 @cindex staff, hiding
728 @cindex staff, empty
729 @cindex hiding staves
730 @cindex hiding ancient staves
731 @cindex hiding rhythmic staves
732 @cindex hiding vaticana staves
733 @cindex empty staves
734
735 @funindex \RemoveEmptyStaves
736 @funindex \RemoveAllEmptyStaves
737 @funindex Staff_symbol_engraver
738 @funindex \stopStaff
739
740
741 Staff lines can be hidden by removing the
742 @code{Staff_symbol_engraver} from the @code{Staff} context.  As an
743 alternative, @code{\stopStaff} may be used.
744
745 @lilypond[verbatim,quote]
746 \new Staff \with {
747   \remove "Staff_symbol_engraver"
748 }
749 \relative { a''8 f e16 d c b a2 }
750 @end lilypond
751
752
753 Empty staves can be hidden (for a so-called @q{Frenched Score})
754 by applying the @code{\RemoveEmptyStaves} command on a context, which
755 can be done globally (in a @code{\layout} block) as well as for
756 specific staves only (in a @code{\with} block).  This command removes
757 all empty staves in a score except for those in the first system.  If
758 you want those in the first system to be hidden also, use
759 @code{\RemoveAllEmptyStaves}.  Supported contexts are @code{Staff},
760 @code{RhythmicStaff} and @code{VaticanaStaff}.
761
762 @warning{A staff is considered empty when it contains only
763 multi-measure rests, rests, skips, spacer rests, or a combination of these
764 elements.}
765
766 @lilypond[verbatim,quote,ragged-right]
767 \layout {
768   \context {
769     \Staff
770     \RemoveEmptyStaves
771   }
772 }
773
774 \relative <<
775   \new Staff {
776     e'4 f g a \break
777     b1 \break
778     a4 b c2
779   }
780   \new Staff {
781     c,4 d e f \break
782     R1 \break
783     f4 g c,2
784   }
785 >>
786 @end lilypond
787
788 @cindex ossia
789
790 @noindent
791 @code{\RemoveAllEmptyStaves} can also be used to create ossia
792 sections for a staff.  For details, see @ref{Ossia staves}.
793
794
795 @predefined
796 @code{\RemoveEmptyStaves},
797 @code{\RemoveAllEmptyStaves}.
798 @endpredefined
799
800 @seealso
801 Music Glossary:
802 @rglos{Frenched staff}.
803
804 Learning Manual:
805 @rlearning{Visibility and color of objects}.
806
807 Notation Reference:
808 @ref{Changing context default settings},
809 @ref{Staff symbol},
810 @ref{Ossia staves},
811 @ref{Hidden notes},
812 @ref{Invisible rests},
813 @ref{Visibility of objects}.
814
815 Snippets:
816 @rlsr{Staff notation}.
817
818 Internals Reference:
819 @rinternals{ChordNames},
820 @rinternals{FiguredBass},
821 @rinternals{Lyrics},
822 @rinternals{Staff},
823 @rinternals{VerticalAxisGroup},
824 @rinternals{Staff_symbol_engraver}.
825
826 @knownissues
827 Removing @code{Staff_symbol_engraver} also hides bar lines.  If
828 bar line visibility is forced, formatting errors may occur.  In
829 this case, use the following overrides instead of removing the
830 engraver:
831
832 @example
833 \omit StaffSymbol
834 \override NoteHead.no-ledgers = ##t
835 @end example
836
837 For the Known issues and warnings associated with
838 @code{\Staff \RemoveEmptyStaves} see
839 @ref{Changing context default settings}.
840
841
842 @node Writing parts
843 @subsection Writing parts
844
845 This section explains how to insert tempo indications and
846 instrument names into a score.  Methods to quote other voices and
847 format cue notes are also described.
848
849 @menu
850 * Instrument names::
851 * Quoting other voices::
852 * Formatting cue notes::
853 @end menu
854
855 @node Instrument names
856 @unnumberedsubsubsec Instrument names
857
858 @cindex instrument names
859 @cindex instrument names, short
860
861 Instrument names can be printed on the left side of staves in the
862 @code{Staff}, @code{PianoStaff}, @code{StaffGroup}, @code{GrandStaff}
863 and @code{ChoirStaff} contexts.  The value of
864 @code{instrumentName} is used for the first staff, and the value
865 of @code{shortInstrumentName} is used for all succeeding staves.
866
867 @lilypond[verbatim,quote,ragged-right]
868 \new Staff \with {
869   instrumentName = #"Violin "
870   shortInstrumentName = #"Vln. "
871 } \relative {
872   c'4.. g'16 c4.. g'16 \break | c1 |
873 }
874 @end lilypond
875
876 @cindex instrument names, complex
877
878 @code{\markup} can be used to create more complex instrument names:
879
880 @lilypond[verbatim,quote]
881 \new Staff \with {
882   instrumentName = \markup {
883     \column { "Clarinetti"
884       \line { "in B" \smaller \flat }
885     }
886   }
887 } \relative {
888   c''4 c,16 d e f g2
889 }
890 @end lilypond
891
892 @cindex instrument names, centering
893
894 When two or more staff contexts are grouped together, the instrument
895 names and short instrument names are centered by default.  To center
896 multi-line instrument names, @code{\center-column} must be used:
897
898 @lilypond[verbatim,quote,indent=1.5\cm]
899 <<
900   \new Staff \with {
901     instrumentName = #"Flute"
902   } \relative {
903     f''2 g4 f
904 }
905   \new Staff \with {
906     instrumentName = \markup {
907       \center-column { "Clarinet"
908         \line { "in B" \smaller \flat }
909       }
910     }
911   } \relative { c''4 b c2 }
912 >>
913 @end lilypond
914
915 @funindex indent
916 @funindex short-indent
917
918 However, if the instrument names are longer, the instrument names in a
919 staff group may not be centered unless the @code{indent} and
920 @code{short-indent} settings are increased.  For details about these
921 settings, see @ref{paper variables for shifts and indents,,@code{@bs{}paper} variables for shifts and indents}.
922
923 @lilypond[verbatim,quote,ragged-right]
924 <<
925   \new Staff \with {
926     instrumentName = #"Alto Flute in G"
927     shortInstrumentName = #"Flt."
928   } \relative {
929     f''2 g4 f \break
930     g4 f g2
931   }
932   \new Staff \with {
933     instrumentName = #"Clarinet"
934     shortInstrumentName = #"Clar."
935   } \relative {
936     c''4 b c2 \break
937     c2 b4 c
938   }
939 >>
940
941 \layout {
942   indent = 3.0\cm
943   short-indent = 1.5\cm
944 }
945 @end lilypond
946
947 @cindex instrument names, adding to other contexts
948
949 To add instrument names to other contexts (such as @code{ChordNames} or
950 @code{FiguredBass}), @code{Instrument_name_engraver} must be added to
951 that context.  For details, see @ref{Modifying context plug-ins}.
952
953 @cindex instrument names, changing
954 @cindex changing instrument names
955
956 The @code{shortInstrumentName} may be changed in the middle of a piece,
957 along with other settings as needed for the new instrument.
958 However, only the first instance of @code{instrumentName} will be
959 printed and subsequent changes will be ignored:
960
961 @lilypond[verbatim,quote,ragged-right]
962 prepPiccolo = <>^\markup \italic { muta in Piccolo }
963
964 setPiccolo = {
965   \set Staff.instrumentName = #"Piccolo"
966   \set Staff.shortInstrumentName = #"Picc."
967   \set Staff.midiInstrument = #"piccolo"
968   <>^\markup \bold { Piccolo }
969   \transposition c''
970 }
971
972 prepFlute = <>^\markup \italic { muta in Flauto }
973
974 setFlute = {
975   \set Staff.instrumentName = #"Flute"
976   \set Staff.shortInstrumentName = #"Flt."
977   \set Staff.midiInstrument = #"flute"
978   <>^\markup \bold { Flute }
979   \transposition c'
980 }
981
982 \new Staff \with {
983   instrumentName = #"Flute"
984   shortInstrumentName = #"Flt."
985   midiInstrument = #"flute"
986 }
987 \relative {
988   g'1 g g g \break
989   g1 g \prepPiccolo R R \break
990   \setPiccolo
991   g1 g g g \break
992   g1 g \prepFlute R R \break
993   \setFlute
994   g1 g g g
995 }
996 @end lilypond
997
998
999 @seealso
1000 Notation Reference:
1001 @ref{paper variables for shifts and indents,,@code{@bs{}paper} variables for shifts and indents},
1002 @ref{Modifying context plug-ins}.
1003
1004 Snippets:
1005 @rlsr{Staff notation}.
1006
1007 Internals Reference:
1008 @rinternals{InstrumentName},
1009 @rinternals{PianoStaff},
1010 @rinternals{Staff}.
1011
1012
1013 @node Quoting other voices
1014 @unnumberedsubsubsec Quoting other voices
1015
1016 @cindex quote, voices
1017 @cindex voices, quoting
1018 @cindex fragments, quoting
1019 @cindex cue notes
1020
1021 @funindex \addQuote
1022 @funindex \quoteDuring
1023 @funindex \transposition
1024
1025 It is very common for one voice to use the same notes as those from
1026 another voice.  For example, first and second violins playing the same
1027 phrase during a particular passage of the music.  This is done by
1028 letting one voice @emph{quote} the other, without having to re-enter the
1029 music all over again for the second voice.
1030
1031 The @code{\addQuote} command, used in the top level scope, defines a
1032 stream of music from which fragments can be quoted.
1033
1034 The @code{\quoteDuring} command is used to indicate the point where the
1035 quotation begins.  It is followed by two arguments: the name of the
1036 quoted voice, as defined with @code{\addQuote}, and a music expression
1037 for the duration of the quote.
1038
1039 @lilypond[verbatim,quote]
1040 fluteNotes = \relative {
1041   a'4 gis g gis | b4^"quoted" r8 ais\p a4( f)
1042 }
1043
1044 oboeNotes = \relative {
1045   c''4 cis c b \quoteDuring #"flute" { s1 }
1046 }
1047
1048 \addQuote "flute" { \fluteNotes }
1049
1050 \score {
1051   <<
1052     \new Staff \with { instrumentName = "Flute" } \fluteNotes
1053     \new Staff \with { instrumentName = "Oboe" } \oboeNotes
1054   >>
1055 }
1056 @end lilypond
1057
1058 If the music expression used in @code{\quoteDuring} contains notes
1059 instead of spacer or multimeasure rests then the quote will appear as
1060 polyphony and may produce unexpected results.
1061
1062 @lilypond[verbatim,quote]
1063 fluteNotes = \relative {
1064   a'4 gis g gis | b4^"quoted" r8 ais\p a4( f)
1065 }
1066
1067 oboeNotes = \relative {
1068   c''4 cis c b \quoteDuring #"flute" { e4 r8 ais b4 a }
1069 }
1070
1071 \addQuote "flute" { \fluteNotes }
1072
1073 \score {
1074   <<
1075     \new Staff \with { instrumentName = "Flute" } \fluteNotes
1076     \new Staff \with { instrumentName = "Oboe" } \oboeNotes
1077   >>
1078 }
1079 @end lilypond
1080
1081 If an @code{\unfoldRepeats} command in a music expression is required to
1082 be printed when using @code{\quoteDuring}, then it too must also contain
1083 its own @code{\unfoldRepeats} command;
1084
1085 @lilypond[verbatim,quote]
1086 fluteNotes = \relative {
1087   \repeat volta 2 { a'4 gis g gis }
1088 }
1089
1090 oboeNotesDW = \relative {
1091   \repeat volta 2 \quoteDuring #"incorrect" { s1 }
1092 }
1093
1094 oboeNotesW = \relative {
1095   \repeat volta 2 \quoteDuring #"correct" { s1 }
1096 }
1097
1098
1099 \addQuote "incorrect" { \fluteNotes }
1100
1101 \addQuote "correct" { \unfoldRepeats \fluteNotes }
1102
1103 \score {
1104   \unfoldRepeats
1105   <<
1106     \new Staff \with { instrumentName = "Flute" }
1107     \fluteNotes
1108     \new Staff \with { instrumentName = "Oboe (incorrect)" }
1109     \oboeNotesDW
1110     \new Staff \with { instrumentName = "Oboe (correct)" }
1111     \oboeNotesW
1112   >>
1113 }
1114 @end lilypond
1115
1116 The @code{\quoteDuring} command uses the @code{\transposition} settings
1117 of both quoted and quoting parts to produce notes for the quoting part
1118 that have the same sounding pitch as those in the quoted part.
1119
1120 @lilypond[verbatim,quote]
1121 clarinetNotes = \relative c'' {
1122   \transposition bes
1123   \key d \major
1124   b4 ais a ais | cis4^"quoted" r8 bis\p b4( f)
1125 }
1126
1127 oboeNotes = \relative {
1128   c''4 cis c b \quoteDuring #"clarinet" { s1 }
1129 }
1130
1131 \addQuote "clarinet" { \clarinetNotes }
1132
1133
1134 \score {
1135   <<
1136     \new Staff \with { instrumentName = "Clarinet" } \clarinetNotes
1137     \new Staff \with { instrumentName = "Oboe" } \oboeNotes
1138   >>
1139 }
1140 @end lilypond
1141
1142 @cindex note-event
1143 @cindex articulation-event
1144 @cindex dynamic-event
1145 @cindex rest-event
1146 @cindex slur-event
1147 @cindex crescendo-event
1148
1149 @funindex quotedEventTypes
1150 @funindex quotedCueEventTypes
1151
1152 By default quoted music will include all articulations, dynamics,
1153 markups, etc., in the quoted expression.  It is possible to choose which
1154 of these objects from the quoted music are displayed by using the
1155 @code{quotedEventTypes} context property.
1156
1157 @lilypond[verbatim,quote]
1158 fluteNotes = \relative {
1159   a'2 g2 |
1160   b4\<^"quoted" r8 ais a4\f( c->)
1161  }
1162
1163 oboeNotes = \relative {
1164   c''2. b4 |
1165   \quoteDuring #"flute" { s1 }
1166 }
1167
1168 \addQuote "flute" { \fluteNotes }
1169
1170 \score {
1171   <<
1172     \set Score.quotedEventTypes = #'(note-event articulation-event
1173                                      crescendo-event rest-event
1174                                      slur-event dynamic-event)
1175     \new Staff \with { instrumentName = "Flute" } \fluteNotes
1176     \new Staff \with { instrumentName = "Oboe" } \oboeNotes
1177   >>
1178  }
1179 @end lilypond
1180
1181 Quotes can also be tagged, see @ref{Using tags}.
1182
1183 @seealso
1184 Notation Reference:
1185 @ref{Instrument transpositions},
1186 @ref{Using tags}.
1187
1188 Installed Files:
1189 @file{scm/define-event-classes.scm}.
1190
1191 Snippets:
1192 @rlsr{Staff notation}.
1193
1194 Internals Reference:
1195 @rinternals{Music classes},
1196 @rinternals{QuoteMusic},
1197 @rinternals{Voice}.
1198
1199 @knownissues
1200 Only the contents of the first @code{Voice} occurring in an
1201 @code{\addQuote} command will be considered for quotation, so if the music
1202 expression contains @code{\new} or @code{\context Voice}
1203 statements, their contents will not be quoted.  Quoting grace notes
1204 is unsupported and may cause LilyPond to crash whereas quoting nested
1205 triplets may result in poor notation.
1206
1207
1208 @node Formatting cue notes
1209 @unnumberedsubsubsec Formatting cue notes
1210
1211 @cindex cue notes
1212 @cindex fragments
1213 @cindex cue notes, formatting
1214 @cindex formatting, cue notes
1215 @cindex voices, quoting
1216
1217
1218 @funindex \cueDuring
1219 @funindex \cueClef
1220 @funindex \cueDuringWithClef
1221 @funindex \quoteDuring
1222
1223 @cindex notes, smaller
1224 @cindex smaller notes
1225 @cindex CueVoice
1226
1227 The simplest way to format cue notes is to explicitly create a
1228 @code{CueVoice} context within the part.
1229
1230 @lilypond[verbatim]
1231 \relative {
1232   R1
1233   <<
1234     { e'2\rest r4. e8 }
1235     \new CueVoice {
1236       \stemUp d'8^"flute" c d e fis2
1237     }
1238   >>
1239   d,4 r a r
1240 }
1241 @end lilypond
1242
1243 The @code{\cueClef} command can also be used with an explict
1244 @code{CueVoice} context if a change of clef is required and will print
1245 an appropriately sized clef for the cue notes.  The @code{\cueClefUnset}
1246 command can then be used to switch back to the original clef, again with
1247 an appropriately sized clef.
1248
1249 @lilypond[verbatim,noragged-right]
1250 \relative {
1251   \clef "bass"
1252   R1
1253   <<
1254     { e'2\rest r4. \cueClefUnset e,8 }
1255     \new CueVoice {
1256       \cueClef "treble" \stemUp d''8^"flute" c d e fis2
1257     }
1258   >>
1259   d,,4 r a r
1260 }
1261 @end lilypond
1262
1263 The @code{\cueClef} and @code{\cueClefUnset} command can also be used
1264 without a @code{CueVoice} if required.
1265
1266 @lilypond[verbatim,noragged-right]
1267 \relative {
1268   \clef "bass"
1269   R1
1270   \cueClef "treble"
1271   d''8^"flute" c d e fis2
1272   \cueClefUnset
1273   d,,4 r a r
1274 }
1275 @end lilypond
1276
1277 For more complex cue note placement, e.g including transposition, or
1278 inserting cue notes from multiple music sources the @code{\cueDuring} or
1279 @code{\cueDuringWithClef} commands can be used.  These are more
1280 specialized form of @code{\quoteDuring}, see @ref{Quoting other voices}
1281 in the previous section.
1282
1283 The syntax is:
1284
1285 @example
1286 \cueDuring #@var{quotename} #@var{direction} #@var{music}
1287 @end example
1288
1289 and
1290
1291 @example
1292 \cueDuringWithClef #@var{quotename} #@var{direction} #@var{clef} #@var{music}
1293 @end example
1294
1295 The music from the corresponding measures of the @code{@var{quote name}}
1296 is added as a @code{CueVoice} context and occurs simultaneously with the
1297 @code{@var{music}}, which then creates a polyphonic situation.  The
1298 @code{@var{direction}} takes the argument @code{UP} or @code{DOWN}, and
1299 corresponds to the first and second voices respectively, determining how
1300 the cue notes are printed in relation to the other voice.
1301
1302 @lilypond[verbatim,quote]
1303 fluteNotes = \relative {
1304   r2. c''4 | d8 c d e fis2 | g2 d |
1305 }
1306
1307 oboeNotes = \relative c'' {
1308   R1
1309   <>^\markup \tiny { flute }
1310   \cueDuring #"flute" #UP { R1 }
1311   g2 c,
1312 }
1313
1314 \addQuote "flute" { \fluteNotes }
1315
1316 \new Staff {
1317   \oboeNotes
1318 }
1319 @end lilypond
1320
1321 @noindent
1322
1323
1324 It is possible to adjust which aspects of the music are quoted with
1325 @code{\cueDuring} by setting the @code{quotedCueEventTypes}
1326 property.  Its default value is @code{'(note-event rest-event
1327 tie-event beam-event tuplet-span-event)}, which means that only
1328 notes, rests, ties, beams and tuplets are quoted, but not
1329 articulations, dynamic marks, markup, etc.
1330
1331 @warning{When a @code{Voice} starts with @code{\cueDuring}, as in the
1332 following example, the @code{Voice} context must be explicitly declared,
1333 or else the entire music expression would belong to the @code{CueVoice}
1334 context.}
1335
1336 @lilypond[verbatim,quote]
1337 oboeNotes = \relative {
1338   r2 r8 d''16(\f f e g f a)
1339   g8 g16 g g2.
1340 }
1341 \addQuote "oboe" { \oboeNotes }
1342
1343 \new Voice \relative c'' {
1344   \set Score.quotedCueEventTypes = #'(note-event rest-event tie-event
1345                                       beam-event tuplet-span-event
1346                                       dynamic-event slur-event)
1347   \cueDuring #"oboe" #UP { R1 }
1348   g2 c,
1349 }
1350 @end lilypond
1351
1352 Markup can be used to show the name of the quoted instrument.
1353 If the cue notes require a change in clef,
1354 this can be done manually but the original clef should also be
1355 restored manually at the end of the cue notes.
1356
1357 @lilypond[verbatim,quote]
1358 fluteNotes = \relative {
1359   r2. c''4 d8 c d e fis2 g2 d2
1360 }
1361
1362 bassoonNotes = \relative c {
1363   \clef bass
1364   R1
1365   \clef treble
1366   <>^\markup \tiny { flute }
1367   \cueDuring #"flute" #UP { R1 }
1368   \clef bass
1369   g4. b8 d2
1370 }
1371
1372 \addQuote "flute" { \fluteNotes }
1373
1374 \new Staff {
1375   \bassoonNotes
1376 }
1377 @end lilypond
1378
1379 Alternatively, the @code{\cueDuringWithClef} function can be used
1380 instead.  This command takes an extra argument to specify the change of
1381 clef that needs to be printed for the cue notes but will automatically
1382 print the original clef once the cue notes have finished.
1383
1384 @lilypond[verbatim,quote]
1385 fluteNotes = \relative {
1386   r2. c''4 d8 c d e fis2 g2 d2
1387 }
1388
1389 bassoonNotes = \relative c {
1390   \clef bass
1391   R1
1392   <>^\markup { \tiny "flute" }
1393   \cueDuringWithClef #"flute" #UP #"treble" { R1 }
1394   g4. b8 d2
1395 }
1396
1397 \addQuote "flute" { \fluteNotes }
1398
1399 \new Staff {
1400   \bassoonNotes
1401 }
1402 @end lilypond
1403
1404 @funindex \transposedCueDuring
1405
1406 Like @code{\quoteDuring}, @code{\cueDuring} takes instrument
1407 transpositions into account.  Cue notes are produced at the
1408 pitches that would be written for the instrument receiving the cue
1409 to produce the sounding pitches of the source instrument.
1410
1411 To transpose cue notes differently, use
1412 @code{\transposedCueDuring}.  This command takes an extra argument
1413 to specify (in absolute mode) the printed pitch that you want to
1414 represent the sound of a concert middle C.  This is useful for
1415 taking cues from an instrument in a completely different register.
1416
1417 @lilypond[verbatim,quote]
1418 piccoloNotes = \relative {
1419   \clef "treble^8"
1420   R1
1421   c'''8 c c e g2
1422   c4 g g2
1423 }
1424
1425 bassClarinetNotes = \relative c' {
1426   \key d \major
1427   \transposition bes,
1428   d4 r a r
1429   \transposedCueDuring #"piccolo" #UP d { R1 }
1430   d4 r a r
1431 }
1432
1433 \addQuote "piccolo" { \piccoloNotes }
1434
1435 <<
1436   \new Staff \piccoloNotes
1437   \new Staff \bassClarinetNotes
1438 >>
1439 @end lilypond
1440
1441 @cindex removing cue notes
1442 @cindex cue notes, removing
1443
1444 @funindex \killCues
1445
1446 The @code{\killCues} command removes cue notes from a music
1447 expression, so the same music expression can be used to produce
1448 the instrument part with cues and the score.  The @code{\killCues}
1449 command removes only the notes and events that were quoted by
1450 @code{\cueDuring}.  Other markup associated with cues, such as clef
1451 changes and a label identifying the source instrument, can be
1452 tagged for selective inclusion in the score; see @ref{Using tags}.
1453
1454 @lilypond[verbatim,quote]
1455 fluteNotes = \relative {
1456   r2. c''4 d8 c d e fis2 g2 d2
1457 }
1458
1459 bassoonNotes = \relative c {
1460   \clef bass
1461   R1
1462   \tag #'part {
1463     \clef treble
1464     <>^\markup \tiny { flute }
1465   }
1466   \cueDuring #"flute" #UP { R1 }
1467   \tag #'part \clef bass
1468   g4. b8 d2
1469 }
1470
1471 \addQuote "flute" { \fluteNotes }
1472
1473 \new Staff {
1474   \bassoonNotes
1475 }
1476
1477 \new StaffGroup <<
1478   \new Staff {
1479     \fluteNotes
1480   }
1481   \new Staff {
1482     \removeWithTag #'part { \killCues { \bassoonNotes } }
1483   }
1484 >>
1485 @end lilypond
1486
1487 Alternatively, Clef changes and instrument labels can be
1488 collected into an instrument definition for repeated use, using
1489 @code{\addInstrumentDefinition} described in @ref{Instrument names}.
1490
1491 @seealso
1492 Notation Reference:
1493 @ref{Quoting other voices},
1494 @ref{Instrument transpositions},
1495 @ref{Instrument names},
1496 @ref{Clef},
1497 @ref{Musical cues},
1498 @ref{Using tags}.
1499
1500 Snippets:
1501 @rlsr{Staff notation}.
1502
1503 Internals Reference:
1504 @rinternals{CueVoice},
1505 @rinternals{Voice}.
1506
1507 @knownissues
1508 Collisions can occur with rests, when using @code{\cueDuring},
1509 between @code{Voice} and @code{CueVoice} contexts.  When using
1510 @code{\cueDuringWithClef} or @code{\transposedCueDuring} the extra
1511 argument required for each case must come after the quote and the
1512 direction.
1513