]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/changing-defaults.itely
b330a99515acd32a1038361ccaf3cb489905a4a0
[lilypond.git] / Documentation / user / changing-defaults.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond.tely
3 @ignore
4     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
5
6     When revising a translation, copy the HEAD committish of the
7     version that you are working on.  See TRANSLATION for details.
8 @end ignore
9
10 @c \version "2.11.55"
11
12 @node Changing defaults
13 @chapter Changing defaults
14
15 @strong{N.B. This Chapter is still being developed at present.}
16
17 The purpose of LilyPond's design is to provide the finest quality
18 output by default.  Nevertheless, it may happen that you need to
19 change this default layout.  The layout is controlled through a large
20 number of @q{knobs and switches} collectively called @q{properties}.
21 A tutorial introduction to accessing and modifying these properties
22 can be found in the Learning Manual, see @rlearning{Tweaking output}.
23 This should be read first.  This chapter covers similar ground, but
24 in a style more appropriate to a reference manual.
25
26 @cindex Internals Reference
27
28 The definitive description of the controls available for tuning can
29 be found in a separate document: @rinternalsnamed{Top,the Internals
30 Reference}.  That manual lists all the variables, functions and
31 options available in LilyPond.  It is written as a HTML document,
32 which is available
33 @c leave the @uref as one long line.
34 @uref{http://@/lilypond@/.org/@/doc/@/stable/@/Documentation/@/user/@/lilypond@/-internals/,on@/-line},
35 and is also included with the LilyPond documentation package.
36
37 @c TODO The following is at variance to what actually follows.  Fix -td
38
39 @ignore
40 There are four areas where the default settings may be changed:
41
42 @itemize
43 @item
44 Automatic notation: changing the automatic creation of notation
45 elements.  For example, changing the beaming rules.
46
47 @item
48 Output: changing the appearance of individual
49 objects.  For example, changing stem directions or the location of
50 subscripts.
51
52 @item
53 Context: changing aspects of the translation from music events to
54 notation.  For example, giving each staff a separate time signature.
55
56 @item
57 Page layout: changing the appearance of the spacing, line
58 breaks, and page dimensions.  These modifications are discussed
59 @c in @ref{notation}, and @ref{Spacing issues}.
60 @end itemize
61
62 Internally, LilyPond uses Scheme (a LISP dialect) to provide
63 infrastructure.  Overriding layout decisions in effect accesses the
64 program internals, which requires Scheme input.  Scheme elements are
65 introduced in a @code{.ly} file with the hash mark
66 @code{#}.@footnote{@rlearning{Scheme tutorial}, contains a short tutorial
67 on entering numbers, lists, strings, and symbols in Scheme.}
68
69 @end ignore
70
71
72 @menu
73 * Interpretation contexts::
74 * Explaining the Internals Reference::
75 * Modifying properties::
76 * Useful concepts and properties::
77 * Common properties::
78 * Advanced tweaks::
79 * Discussion of specific tweaks::
80 @end menu
81
82
83 @node Interpretation contexts
84 @section Interpretation contexts
85
86 This section describes what contexts are, and how to modify them.
87
88 @menu
89 * Contexts explained::          
90 * Creating contexts::           
91 * Modifying context plug-ins::  
92 * Changing context default settings::  
93 * Defining new contexts::       
94 * Aligning contexts::           
95 @end menu
96
97
98 @node Contexts explained
99 @subsection Contexts explained
100
101 @ignore
102 @c TODO Rethink and rewrite
103
104 >> > > - list of contexts: my *danger unmaintainable*
105 >> > > alarm just went off.  I'm
106
107 I knew it would... And leaving out some of them is perfectly fine
108 with me.
109 I do think that a list like this, with the main contexts and a
110 brief
111 description of  what they do (perhaps also with a note about what
112 default
113 behavior is associated with each of them, but this may be
114 unmanageable),
115 should be there, and then we could simply list the remaining ones
116 without
117 further explanation and with links to the IR.
118 @end ignore
119
120 @c TODO Improve layout, order and consistency of wording -td
121
122 @c TODO Add introduction which explains contexts in generality  -td
123
124 Contexts are arranged heirarchically:
125
126 @menu
127 * Score - the master of all contexts::  
128 * Top-level contexts - staff containers::  
129 * Intermediate-level contexts - staves::  
130 * Bottom-level contexts - voices::  
131 @end menu
132
133 @node Score - the master of all contexts
134 @unnumberedsubsubsec Score - the master of all contexts
135
136 This is the top level notation context. No other context can
137 contain a Score context. By default the Score context handles
138 the administration of time signatures and makes sure that items
139 such as clefs, time signatures, and key-signatures are aligned
140 across staves.
141
142 A Score context is instantiated implicitly when a
143 @code{\score @{@dots{}@}} or @code{\layout @{@dots{}@}} block is
144 processed, or explicitly when a @code{\new Score} command is
145 executed.
146
147 @node Top-level contexts - staff containers
148 @unnumberedsubsubsec Top-level contexts - staff containers
149
150 @strong{@emph{StaffGroup}}
151
152 Groups staves while adding a bracket on the left side, grouping
153 the staves together. The bar lines of the contained staves are
154 connected vertically. StaffGroup only consists of a collection
155 of staves, with a bracket in front and spanning bar lines.
156
157 @strong{@emph{ChoirStaff}}
158
159 Identical to StaffGroup except that the bar lines of the contained
160 staves are not connected vertically.
161
162 @strong{@emph{GrandStaff}}
163
164 A group of staves, with a brace on the left side, grouping
165 the staves together. The bar lines of the contained staves are
166 connected vertically.
167
168 @strong{@emph{PianoStaff}}
169
170 TODO No longer correct?  Check.  -td
171
172 Just like GrandStaff but with a forced distance between the
173 staves, so cross staff beaming and slurring can be used.
174
175 @strong{@emph{InnerStaffGroup}}
176
177 TODO  -td
178
179 @strong{@emph{InnerChoirStaff}}
180
181 TODO  -td
182
183 @node Intermediate-level contexts - staves
184 @unnumberedsubsubsec Intermediate-level contexts - staves
185
186 @strong{@emph{Staff}}
187
188 Handles clefs, bar lines, keys, accidentals. It can contain
189 Voice contexts.
190
191 @strong{@emph{RhythmicStaff}}
192
193 Like Staff but for printing rhythms. Pitches are ignored;
194 the notes are printed on one line.
195
196 @strong{@emph{TabStaff}}
197
198 Context for generating tablature. By default lays the music
199 expression out as a guitar tablature, printed on six lines.
200
201 @strong{@emph{DrumStaff}}
202
203 Handles typesetting for percussion. Can contain DrumVoice
204
205 @strong{@emph{VaticanaStaff}}
206
207 Same as Staff, except that it is designed for typesetting
208 a piece in gregorian style.
209
210 @strong{@emph{MensuralStaff}}
211
212 Same as Staff, except that it is designed for typesetting
213 a piece in mensural style.
214
215 @node Bottom-level contexts - voices
216 @unnumberedsubsubsec Bottom-level contexts - voices
217
218 Voice-level contexts initialise certain properties and start
219 appropriate engravers.  Being bottom-level contexts, they cannot
220 contain other contexts.
221
222 @strong{@emph{Voice}}
223
224 Corresponds to a voice on a staff. This context handles the
225 conversion of dynamic signs, stems, beams, super- and sub-scripts,
226 slurs, ties, and rests.  You have to instantiate this explicitly
227 if you require multiple voices on the same staff.
228
229 @strong{@emph{VaticanaVoice}}
230
231 Same as Voice, except that it is designed for typesetting a piece
232 in gregorian style.
233
234 @strong{@emph{MensuralVoice}}
235
236 Same as Voice, with modifications for typesetting a piece in
237 mensural style.
238
239 @strong{@emph{Lyrics}}
240
241 Corresponds to a voice with lyrics. Handles the printing of a
242 single line of lyrics.
243
244 @strong{@emph{DrumVoice}}
245
246 The voice context used in a percussion staff.
247
248 @strong{@emph{FiguredBass}}
249
250 The context in which BassFigure objects are created from
251 input entered in @code{\figuremode} mode.
252
253 @strong{@emph{TabVoice}}
254
255 The voice context used within a TabStaff context.  Usually left to
256 be created implicitly.
257
258 @strong{@emph{ChordNames}}
259
260 Typesets chord names.
261
262 ------------------------------
263
264 TODO
265
266 Then the following, which I don't know what to do with:
267
268     * GregorianTranscriptionVoice
269     * GregorianTranscriptionStaff
270
271     * FretBoards
272         Engraves fretboards from chords. Not easy... Not
273 documented.
274         There is now some documentation on FretBoards in the NR, under
275          instrument-specific notation -- cds.
276
277     * NoteNames
278
279     * CueVoice Not documented
280     * Global
281         Hard coded entry point for LilyPond. Cannot be tuned.
282     * Devnull
283         Silently discards all musical information given to this
284 context.
285
286
287 @node Creating contexts
288 @subsection Creating contexts
289
290 @c TODO \new Score and \score
291 @c TODO more complete descriptions rather than learning style
292
293 For scores with only one voice and one staff, contexts are
294 created automatically.  For more complex scores, it is necessary to
295 create them by hand.  There are three commands that do this.
296
297 @itemize
298
299 @item
300 The easiest command is @code{\new}, and it also the quickest to type.
301 It is prepended to a music expression, for example
302
303 @funindex \new
304 @cindex new contexts
305 @cindex Context, creating
306
307 @example
308 \new @var{type} @var{music expression}
309 @end example
310
311 @noindent
312 where @var{type} is a context name (like @code{Staff} or
313 @code{Voice}).  This command creates a new context, and starts
314 interpreting the @var{music expression} with that.
315
316 A practical application of @code{\new} is a score with many
317 staves.  Each part that should be on its own staff, is preceded with
318 @code{\new Staff}.
319
320 @lilypond[quote,verbatim,relative=2,ragged-right,fragment]
321 <<
322   \new Staff { c4 c }
323   \new Staff { d4 d }
324 >>
325 @end lilypond
326
327 The @code{\new} command may also give a name to the context,
328
329 @example
330 \new @var{type} = @var{id} @var{music}
331 @end example
332 However, this user specified name is only used if there is no other
333 context already earlier with the same name.
334
335
336 @funindex \context
337
338 @item
339 Like @code{\new}, the @code{\context} command also directs a music
340 expression to a context object, but gives the context an explicit name.  The
341 syntax is
342
343 @example
344 \context @var{type} = @var{id} @var{music}
345 @end example
346
347 This form will search for an existing context of type @var{type}
348 called @var{id}.  If that context does not exist yet, a new
349 context with the specified name is created.  This is useful if
350 the context is referred to later on.  For example, when
351 setting lyrics the melody is in a named context
352
353 @example
354 \context Voice = "@b{tenor}" @var{music}
355 @end example
356
357 @noindent
358 so the texts can be properly aligned to its notes,
359
360 @example
361 \new Lyrics \lyricsto "@b{tenor}" @var{lyrics}
362 @end example
363
364 @noindent
365
366 Another possible use of named contexts is funneling two different
367 music expressions into one context.  In the following example,
368 articulations and notes are entered separately,
369
370 @example
371 music = @{ c4 c4 @}
372 arts = @{ s4-. s4-> @}
373 @end example
374
375 They are combined by sending both to the same @code{Voice} context,
376
377 @example
378 <<
379   \new Staff \context Voice = "A" \music
380   \context Voice = "A" \arts
381 >>
382 @end example
383 @lilypond[quote,ragged-right]
384 music = { c4 c4 }
385 arts = { s4-. s4-> }
386 \relative c'' <<
387   \new Staff \context Voice = "A" \music
388   \context Voice = "A" \arts
389 >>
390 @end lilypond
391
392 With this mechanism, it is possible to define an Urtext (original
393 edition), with the option to put several distinct articulations on the
394 same notes.
395
396 @cindex creating contexts
397
398 @item
399 The third command for creating contexts is
400 @example
401 \context @var{type} @var{music}
402 @end example
403
404
405 @noindent
406 This is similar to @code{\context} with @code{= @var{id}}, but matches
407 any context of type @var{type}, regardless of its given name.
408
409 This variant is used with music expressions that can be interpreted at
410 several levels.  For example, the @code{\applyOutput} command (see
411 @ref{Running a function on all layout objects}).  Without an explicit
412 @code{\context}, it is usually applied to @code{Voice}
413
414 @example
415 \applyOutput #'@var{context} #@var{function}   % apply to Voice
416 @end example
417
418 To have it interpreted at the @code{Score} or @code{Staff} level use
419 these forms
420
421 @example
422 \applyOutput #'Score #@var{function}
423 \applyOutput #'Staff #@var{function}
424 @end example
425
426 @end itemize
427
428
429 @node Modifying context plug-ins
430 @subsection Modifying context plug-ins
431
432 @c TODO Should this be Modifying engravers or Modifying contexts?
433
434 Notation contexts (like @code{Score} and @code{Staff}) not only
435 store properties,
436 they also contain plug-ins called @q{engravers} that create notation
437 elements.  For example, the @code{Voice} context contains a
438 @code{Note_head_engraver} and the @code{Staff} context contains a
439 @code{Key_signature_engraver}.
440
441 For a full a description of each plug-in, see
442 @ifhtml
443 @rinternals{Engravers and Performers}.
444 @end ifhtml
445 @ifnothtml
446 Internals Reference @expansion{} Translation @expansion{} Engravers.
447 @end ifnothtml
448 Every context described in
449 @ifhtml
450 @rinternals{Contexts}
451 @end ifhtml
452 @ifnothtml
453 Internals Reference @expansion{} Translation @expansion{} Context.
454 @end ifnothtml
455 lists the engravers used for that context.
456
457
458 It can be useful to shuffle around these plug-ins.  This is done by
459 starting a new context with @code{\new} or @code{\context}, and
460 modifying it,
461
462 @funindex \with
463
464 @example
465 \new @var{context} \with @{
466   \consists @dots{}
467   \consists @dots{}
468   \remove @dots{}
469   \remove @dots{}
470   @emph{etc.}
471 @}
472 @{
473   @emph{..music..}
474 @}
475 @end example
476
477 @noindent
478 where the @dots{} should be the name of an engraver.  Here is a simple
479 example which removes @code{Time_signature_engraver} and
480 @code{Clef_engraver} from a @code{Staff} context,
481
482 @lilypond[quote,relative=1,verbatim,fragment]
483 <<
484   \new Staff {
485     f2 g
486   }
487   \new Staff \with {
488      \remove "Time_signature_engraver"
489      \remove "Clef_engraver"
490   } {
491     f2 g2
492   }
493 >>
494 @end lilypond
495
496 In the second staff there are no time signature or clef symbols.  This
497 is a rather crude method of making objects disappear since it will affect
498 the entire staff.  This method also influences the spacing, which may or
499 may not be desirable.  More sophisticated methods of blanking objects
500 are shown in @rlearning{Visibility and color of objects}.
501
502 The next example shows a practical application.  Bar lines and time
503 signatures are normally synchronized across the score.  This is done
504 by the @code{Timing_translator} and @code{Default_bar_line_engraver}.
505 This plug-in keeps an administration of time signature, location
506 within the measure, etc.  By moving these engraver from @code{Score} to
507 @code{Staff} context, we can have a score where each staff has its own
508 time signature.
509
510 @cindex polymetric scores
511 @cindex Time signatures, multiple
512
513 @lilypond[quote,relative=1,ragged-right,verbatim,fragment]
514 \new Score \with {
515   \remove "Timing_translator"
516   \remove "Default_bar_line_engraver"
517 } <<
518   \new Staff \with {
519     \consists "Timing_translator"
520     \consists "Default_bar_line_engraver"
521   } {
522       \time 3/4
523       c4 c c c c c
524   }
525   \new Staff \with {
526     \consists "Timing_translator"
527     \consists "Default_bar_line_engraver"
528   } {
529        \time 2/4
530        c4 c c c c c
531   }
532 >>
533 @end lilypond
534
535
536 @node Changing context default settings
537 @subsection Changing context default settings
538
539 The adjustments of the previous subsections (
540 @ref{The set command}, @ref{Modifying context plug-ins}, and
541 @ref{Overview of modifying properties}) can also be entered
542 separately from the music in the @code{\layout} block,
543
544 @example
545 \layout @{
546   @dots{}
547   \context @{
548     \Staff
549
550     \set fontSize = #-2
551     \override Stem #'thickness = #4.0
552     \remove "Time_signature_engraver"
553   @}
554 @}
555 @end example
556
557 The @code{\Staff} command brings in the existing definition of the
558 staff context so that it can be modified.
559
560 The statements
561 @example
562 \set fontSize = #-2
563 \override Stem #'thickness = #4.0
564 \remove "Time_signature_engraver"
565 @end example
566
567 @noindent
568 affect all staves in the score.  Other contexts can be modified
569 analogously.
570
571 The @code{\set} keyword is optional within the @code{\layout} block, so
572
573 @example
574 \context @{
575   @dots{}
576   fontSize = #-2
577 @}
578 @end example
579
580 @noindent
581 will also work.
582
583
584
585 @knownissues
586
587 It is not possible to collect context changes in a variable and apply
588 them to a @code{\context} definition by referring to that variable.
589
590 The @code{\RemoveEmptyStaffContext} will overwrite your current
591 @code{\Staff} settings.  If you wish to change the defaults for a
592 staff which uses @code{\RemoveEmptyStaffContext}, you must do so
593 after calling @code{\RemoveEmptyStaffContext}, ie
594
595 @example
596 \layout @{
597   \context @{
598     \RemoveEmptyStaffContext
599
600     \override Stem #'thickness = #4.0
601   @}
602 @}
603 @end example
604
605 TODO: add \with in here.
606
607
608
609 @node Defining new contexts
610 @subsection Defining new contexts
611
612 Specific contexts, like @code{Staff} and @code{Voice}, are made of
613 simple building blocks.  It is possible to create new types of
614 contexts with different combinations of engraver plug-ins.
615
616 The next example shows how to build a different type of
617 @code{Voice} context from scratch.  It will be similar to
618 @code{Voice}, but only prints centered slash note heads.  It can be used
619 to indicate improvisation in jazz pieces,
620
621 @lilypond[quote,ragged-right]
622 \layout { \context {
623   \name ImproVoice
624   \type "Engraver_group"
625   \consists "Note_heads_engraver"
626   \consists "Text_engraver"
627   \consists Pitch_squash_engraver
628   squashedPosition = #0
629   \override NoteHead #'style = #'slash
630   \override Stem #'transparent = ##t
631   \alias Voice
632 }
633 \context { \Staff
634   \accepts "ImproVoice"
635 }}
636
637 \relative c'' {
638   a4 d8 bes8 \new ImproVoice { c4^"ad lib" c
639    c4 c^"undress" c_"while playing :)" c }
640   a1
641 }
642 @end lilypond
643
644
645 These settings are defined within a @code{\context} block inside a
646 @code{\layout} block,
647
648 @example
649 \layout @{
650   \context @{
651     @dots{}
652   @}
653 @}
654 @end example
655
656 In the following discussion, the example input shown should go in place
657 of the @dots{} in the previous fragment.
658
659 First it is necessary to define a name for the new context:
660
661 @example
662 \name ImproVoice
663 @end example
664
665 Since it is similar to the @code{Voice}, we want commands that work
666 on (existing) @code{Voice}s to remain working.  This is achieved by
667 giving the new context an alias @code{Voice},
668
669 @example
670 \alias Voice
671 @end example
672
673 The context will print notes and instructive texts, so we need to add
674 the engravers which provide this functionality,
675
676 @example
677 \consists Note_heads_engraver
678 \consists Text_engraver
679 @end example
680
681 but we only need this on the center line,
682
683 @example
684 \consists Pitch_squash_engraver
685 squashedPosition = #0
686 @end example
687
688 The @rinternals{Pitch_squash_engraver} modifies note heads (created
689 by @rinternals{Note_heads_engraver}) and sets their vertical
690 position to the value of @code{squashedPosition}, in this case@tie{}@code{0},
691 the center line.
692
693 The notes look like a slash, and have no stem,
694
695 @example
696 \override NoteHead #'style = #'slash
697 \override Stem #'transparent = ##t
698 @end example
699
700 All these plug-ins have to cooperate, and this is achieved with a
701 special plug-in, which must be marked with the keyword @code{\type}.
702 This should always be @code{Engraver_group}.
703
704 @example
705 \type "Engraver_group"
706 @end example
707
708 Put together, we get
709
710 @example
711 \context @{
712   \name ImproVoice
713   \type "Engraver_group"
714   \consists "Note_heads_engraver"
715   \consists "Text_engraver"
716   \consists Pitch_squash_engraver
717   squashedPosition = #0
718   \override NoteHead #'style = #'slash
719   \override Stem #'transparent = ##t
720   \alias Voice
721 @}
722 @end example
723
724 @funindex \accepts
725 Contexts form hierarchies.  We want to hang the @code{ImproVoice}
726 under @code{Staff}, just like normal @code{Voice}s.  Therefore, we
727 modify the @code{Staff} definition with the @code{\accepts}
728 command,
729
730 @example
731 \context @{
732   \Staff
733   \accepts ImproVoice
734 @}
735 @end example
736
737 @funindex \denies
738 The opposite of @code{\accepts} is @code{\denies},
739 which is sometimes needed when reusing existing context definitions.
740
741 Putting both into a @code{\layout} block, like
742
743 @example
744 \layout @{
745   \context @{
746     \name ImproVoice
747     @dots{}
748   @}
749   \context @{
750     \Staff
751     \accepts "ImproVoice"
752   @}
753 @}
754 @end example
755
756 Then the output at the start of this subsection can be entered as
757
758 @example
759 \relative c'' @{
760   a4 d8 bes8
761   \new ImproVoice @{
762     c4^"ad lib" c
763     c4 c^"undress"
764     c c_"while playing :)"
765   @}
766   a1
767 @}
768 @end example
769
770
771 @node Aligning contexts
772 @subsection Aligning contexts
773
774 New contexts may be aligned above or below existing contexts.  This
775 could be useful in setting up a vocal staff (@rlearning{Vocal ensembles}) and
776 in ossia,
777
778 @c TODO Better example needed.  Ref LM, and expand on it.
779
780 @cindex ossia
781 @findex alignAboveContext
782 @findex alignBelowContext
783
784 @lilypond[quote,ragged-right]
785 ossia = { f4 f f f }
786 \score{
787   \relative c' \new Staff = "main" {
788     c4 c c c
789     <<
790       \new Staff \with {alignAboveContext=main} \ossia
791       { d8 f d f d f d f }
792     >>
793   }
794 }
795 @end lilypond
796
797
798 @node Explaining the Internals Reference
799 @section Explaining the Internals Reference
800
801
802 @menu
803 * Navigating the program reference::  
804 * Layout interfaces::           
805 * Determining the grob property::  
806 * Naming conventions::          
807 @end menu
808
809 @node Navigating the program reference
810 @subsection Navigating the program reference
811
812 @c TODO remove this (it's in the LM)
813 @c Replace with more factual directions
814
815 Suppose we want to move the fingering indication in the fragment
816 below:
817
818 @lilypond[quote,fragment,relative=2,verbatim]
819 c-2
820 \stemUp
821 f
822 @end lilypond
823
824 If you visit the documentation on fingering instructions (in
825 @ref{Fingering instructions}), you will notice:
826
827 @quotation
828 @strong{See also}
829
830 Internals Reference: @rinternals{Fingering}.
831
832 @end quotation
833
834
835 @c  outdated info; probably will delete.
836 @ignore
837 This fragment points to two parts of the program reference: a page
838 on @code{FingeringEvent} and one on @code{Fingering}.
839
840 The page on @code{FingeringEvent} describes the properties of the music
841 expression for the input @code{-2}.  The page contains many links
842 forward.  For example, it says
843
844 @quotation
845 Accepted by: @rinternals{Fingering_engraver},
846 @end quotation
847
848 @noindent
849 That link brings us to the documentation for the Engraver, the
850 plug-in, which says
851
852 @quotation
853 This engraver creates the following layout objects: @rinternals{Fingering}.
854 @end quotation
855
856 In other words, once the @code{FingeringEvent}s are interpreted, the
857 @code{Fingering_engraver} plug-in will process them.
858 @end ignore
859
860 @ignore
861 @c  I can't figure out what this is supposed to mean.  -gp
862
863 The @code{Fingering_engraver} is also listed to create
864 @rinternals{Fingering} objects,
865
866 @c  old info?  it doesn't make any sense to me with our current docs.
867 This is also the
868 second bit of information listed under @b{See also} in the Notation
869 manual.
870 @end ignore
871
872 @ifnothtml
873 The programmer's reference is available as an HTML document.  It is
874 highly recommended that you read it in HTML form, either online or
875 by downloading the HTML documentation.  This section will be much more
876 difficult to understand if you are using the
877 PDF manual.
878 @end ifnothtml
879
880 Follow the link to @rinternals{Fingering}.  At the top of the
881 page, you will see
882
883 @quotation
884 Fingering objects are created by: @rinternals{Fingering_engraver} and
885 @rinternals{New_fingering_engraver}.
886 @end quotation
887
888 By following related links inside the program reference, we can follow the
889 flow of information within the program:
890
891 @itemize
892
893 @item @rinternals{Fingering}:
894 @rinternals{Fingering} objects are created by:
895 @rinternals{Fingering_engraver}
896
897 @item @rinternals{Fingering_engraver}:
898 Music types accepted: @rinternals{fingering-event}
899
900 @item @rinternals{fingering-event}:
901 Music event type @code{fingering-event} is in Music expressions named
902 @rinternals{FingeringEvent}
903 @end itemize
904
905 This path goes against the flow of information in the program: it
906 starts from the output, and ends at the input event.  You could
907 also start at an input event, and read with the flow of
908 information, eventually ending up at the output object(s).
909
910 The program reference can also be browsed like a normal document.  It
911 contains chapters on
912 @ifhtml
913 @rinternals{Music definitions},
914 @end ifhtml
915 @ifnothtml
916 @code{Music definitions}
917 @end ifnothtml
918 on @rinternals{Translation}, and the @rinternals{Backend}.  Every
919 chapter lists all the definitions used and all properties that may be
920 tuned.
921
922
923 @node Layout interfaces
924 @subsection Layout interfaces
925
926 @cindex interface, layout
927 @cindex layout interface
928 @cindex grob
929
930 The HTML page that we found in the previous section describes the
931 layout object called @rinternals{Fingering}.  Such an object is a
932 symbol within the score.  It has properties that store numbers (like
933 thicknesses and directions), but also pointers to related objects.  A
934 layout object is also called a @emph{Grob}, which is short for Graphical
935 Object.  For more details about Grobs, see @rinternals{grob-interface}.
936
937 The page for @code{Fingering} lists the definitions for the
938 @code{Fingering} object.  For example, the page says
939
940 @quotation
941 @code{padding} (dimension, in staff space):
942
943 @code{0.5}
944 @end quotation
945
946 @noindent
947 which means that the number will be kept at a distance of at least 0.5
948 of the note head.
949
950
951 Each layout object may have several functions as a notational or
952 typographical element.  For example, the Fingering object
953 has the following aspects
954
955 @itemize
956 @item
957 Its size is independent of the horizontal spacing, unlike slurs or beams.
958
959 @item
960 It is a piece of text.  Granted, it is usually a very short text.
961
962 @item
963 That piece of text is typeset with a font, unlike slurs or beams.
964
965 @item
966 Horizontally, the center of the symbol should be aligned to the
967 center of the note head.
968
969 @item
970 Vertically, the symbol is placed next to the note and the staff.
971
972 @item
973 The vertical position is also coordinated with other superscript
974 and subscript symbols.
975 @end itemize
976
977 Each of these aspects is captured in so-called @emph{interface}s,
978 which are listed on the @rinternals{Fingering} page at the bottom
979
980 @quotation
981 This object supports the following interfaces:
982 @rinternals{item-interface},
983 @rinternals{self-alignment-interface},
984 @rinternals{side-position-interface}, @rinternals{text-interface},
985 @rinternals{text-script-interface}, @rinternals{font-interface},
986 @rinternals{finger-interface}, and @rinternals{grob-interface}.
987 @end quotation
988
989 Clicking any of the links will take you to the page of the respective
990 object interface.  Each interface has a number of properties.  Some of
991 them are not user-serviceable (@q{Internal properties}), but others
992 can be modified.
993
994 We have been talking of @emph{the} @code{Fingering} object, but actually it
995 does not amount to much.  The initialization file (see
996 @rlearning{Other sources of information})
997 @file{scm/@/define@/-grobs@/.scm} shows the soul of the @q{object},
998
999 @example
1000 (Fingering
1001   . ((padding . 0.5)
1002      (avoid-slur . around)
1003      (slur-padding . 0.2)
1004      (staff-padding . 0.5)
1005      (self-alignment-X . 0)
1006      (self-alignment-Y . 0)
1007      (script-priority . 100)
1008      (stencil . ,ly:text-interface::print)
1009      (direction . ,ly:script-interface::calc-direction)
1010      (font-encoding . fetaNumber)
1011      (font-size . -5)           ; don't overlap when next to heads.
1012      (meta . ((class . Item)
1013      (interfaces . (finger-interface
1014                     font-interface
1015                     text-script-interface
1016                     text-interface
1017                     side-position-interface
1018                     self-alignment-interface
1019                     item-interface))))))
1020 @end example
1021
1022 @noindent
1023 As you can see, the @code{Fingering} object is nothing more than a
1024 bunch of variable settings, and the webpage in the Internals Reference
1025 is directly generated from this definition.
1026
1027
1028 @node Determining the grob property
1029 @subsection Determining the grob property
1030
1031 @c TODO remove this (it's in the LM)
1032 @c Replace with more factual directions
1033
1034 Recall that we wanted to change the position of the @b{2} in
1035
1036 @lilypond[quote,fragment,relative=2,verbatim]
1037 c-2
1038 \stemUp
1039 f
1040 @end lilypond
1041
1042 Since the @b{2} is vertically positioned next to its note, we have to
1043 meddle with the interface associated with this positioning.  This is
1044 done using @code{side-position-interface}.  The page for this interface
1045 says
1046
1047 @quotation
1048 @code{side-position-interface}
1049
1050 Position a victim object (this one) next to other objects (the
1051 support).  The property @code{direction} signifies where to put the
1052 victim object relative to the support (left or right, up or down?)
1053 @end quotation
1054
1055 @cindex padding
1056 @noindent
1057 Below this description, the variable @code{padding} is described as
1058
1059 @quotation
1060 @table @code
1061 @item padding
1062 (dimension, in staff space)
1063
1064 Add this much extra space between objects that are next to each other.
1065 @end table
1066 @end quotation
1067
1068 By increasing the value of @code{padding}, we can move the
1069 fingering away from the note head.  The following command inserts
1070 3 staff spaces of white
1071 between the note and the fingering:
1072 @example
1073 \once \override Voice.Fingering #'padding = #3
1074 @end example
1075
1076 Inserting this command before the Fingering object is created,
1077 i.e., before @code{c2}, yields the following result:
1078
1079 @lilypond[quote,relative=2,fragment,verbatim]
1080 \once \override Voice.Fingering #'padding = #3
1081 c-2
1082 \stemUp
1083 f
1084 @end lilypond
1085
1086
1087 In this case, the context for this tweak is @code{Voice}.  This
1088 fact can also be deduced from the program reference, for the page for
1089 the @rinternals{Fingering_engraver} plug-in says
1090
1091 @quotation
1092 Fingering_engraver is part of contexts: @dots{} @rinternals{Voice}
1093 @end quotation
1094
1095
1096 @node Naming conventions
1097 @subsection Naming conventions
1098
1099 Another thing that is needed, is an overview of the various naming
1100 conventions:
1101
1102     scheme functions: lowercase-with-hyphens (incl. one-word
1103 names)
1104     scheme functions: ly:plus-scheme-style
1105     music events, music classes and music properties:
1106 as-scheme-functions
1107     Grob interfaces: scheme-style
1108     backend properties: scheme-style (but X and Y!)
1109     contexts (and MusicExpressions and grobs): Capitalized or
1110 CamelCase
1111     context properties: lowercaseFollowedByCamelCase
1112     engravers:
1113 Capitalized_followed_by_lowercase_and_with_underscores
1114
1115 Which of these are conventions and which are rules?
1116 Which are rules of the underlying language, and which are
1117 LP-specific?
1118
1119
1120 @node Modifying properties
1121 @section Modifying properties
1122
1123 @c TODO change the menu and subsection node names to use
1124 @c backslash once the new macro to handle the refs
1125 @c is available.  Need to find and change all refs at
1126 @c the same time. -td
1127
1128 @menu
1129 * Overview of modifying properties::
1130 * The set command::
1131 * The override command::
1132 * The tweak command::
1133 * set versus override::
1134 @end menu
1135
1136
1137 @node Overview of modifying properties
1138 @subsection Overview of modifying properties
1139
1140 Each context is responsible for creating certain types of graphical
1141 objects.  The settings used for printing these objects are also stored by
1142 context.  By changing these settings, the appearance of objects can be
1143 altered.
1144
1145 The syntax for this is
1146
1147 @example
1148 \override @var{context}.@var{name} #'@var{property} = #@var{value}
1149 @end example
1150
1151 Here @var{name} is the name of a graphical object, like
1152 @code{Stem} or @code{NoteHead}, and @var{property} is an internal
1153 variable of the formatting system (@q{grob property} or @q{layout
1154 property}).  The latter is a symbol, so it must be quoted.  The
1155 subsection @ref{Modifying properties}, explains what to fill in
1156 for @var{name}, @var{property}, and @var{value}.  Here we only
1157 discuss the functionality of this command.
1158
1159 The command
1160
1161 @verbatim
1162 \override Staff.Stem #'thickness = #4.0
1163 @end verbatim
1164
1165 @noindent
1166 makes stems thicker (the default is 1.3, with staff line thickness as a
1167 unit).  Since the command specifies @code{Staff} as context, it only
1168 applies to the current staff.  Other staves will keep their normal
1169 appearance.  Here we see the command in action:
1170
1171 @lilypond[quote,verbatim,relative=2,fragment]
1172 c4
1173 \override Staff.Stem #'thickness = #4.0
1174 c4
1175 c4
1176 c4
1177 @end lilypond
1178
1179 The @code{\override} command changes the definition of the @code{Stem}
1180 within the current @code{Staff}.  After the command is interpreted
1181 all stems are thickened.
1182
1183 Analogous to @code{\set}, the @var{context} argument may be left out,
1184 causing the default context @code{Voice} to be used.  Adding
1185 @code{\once} applies the change during one timestep only.
1186
1187 @lilypond[quote,fragment,verbatim,relative=2]
1188 c4
1189 \once \override Stem #'thickness = #4.0
1190 c4
1191 c4
1192 @end lilypond
1193
1194 The @code{\override} must be done before the object is
1195 started.  Therefore, when altering @emph{Spanner} objects such as slurs
1196 or beams, the @code{\override} command must be executed at the moment
1197 when the object is created.  In this example,
1198
1199 @lilypond[quote,fragment,verbatim,relative=2]
1200 \override Slur #'thickness = #3.0
1201 c8[( c
1202 \override Beam #'thickness = #0.6
1203 c8 c])
1204 @end lilypond
1205
1206 @noindent
1207 the slur is fatter but the beam is not.  This is because the command for
1208 @code{Beam} comes after the Beam is started, so it has no effect.
1209
1210 Analogous to @code{\unset}, the @code{\revert} command for a context
1211 undoes an @code{\override} command; like with @code{\unset}, it only
1212 affects settings that were made in the same context.  In other words, the
1213 @code{\revert} in the next example does not do anything.
1214
1215 @example
1216 \override Voice.Stem #'thickness = #4.0
1217 \revert Staff.Stem #'thickness
1218 @end example
1219
1220 Some tweakable options are called @q{subproperties} and reside inside
1221 properties.  To tweak those, use commands of the form
1222
1223 @c leave this as a long long
1224 @example
1225 \override @var{context}.@var{name} #'@var{property} #'@var{subproperty} = #@var{value}
1226 @end example
1227
1228 @noindent
1229 such as
1230
1231 @example
1232 \override Stem #'details #'beamed-lengths = #'(4 4 3)
1233 @end example
1234
1235
1236 @seealso
1237
1238 Internals: @rinternals{OverrideProperty}, @rinternals{RevertProperty},
1239 @rinternals{PropertySet}, @rinternals{Backend}, and
1240 @rinternals{All layout objects}.
1241
1242
1243 @knownissues
1244
1245 The back-end is not very strict in type-checking object properties.
1246 Cyclic references in Scheme values for properties can cause hangs
1247 or crashes, or both.
1248
1249
1250
1251 @node The set command
1252 @subsection The @code{\set} command
1253
1254 @cindex properties
1255 @funindex \set
1256 @cindex changing properties
1257
1258 Each context can have different @emph{properties}, variables contained
1259 in that context.  They can be changed during the interpretation step.
1260 This is achieved by inserting the @code{\set} command in the music,
1261
1262 @example
1263 \set @var{context}.@var{prop} = #@var{value}
1264 @end example
1265
1266 For example,
1267 @lilypond[quote,verbatim,relative=2,fragment]
1268 R1*2
1269 \set Score.skipBars = ##t
1270 R1*2
1271 @end lilypond
1272
1273 This command skips measures that have no notes.  The result is that
1274 multi-rests are condensed.  The value assigned is a Scheme object.  In
1275 this case, it is @code{#t}, the boolean True value.
1276
1277 If the @var{context} argument is left out, then the current bottom-most
1278 context (typically @code{ChordNames}, @code{Voice}, or
1279 @code{Lyrics}) is used.  In this example,
1280
1281 @lilypond[quote,verbatim,relative=2,fragment]
1282 c8 c c c
1283 \set autoBeaming = ##f
1284 c8 c c c
1285 @end lilypond
1286
1287 @noindent
1288 the @var{context} argument to @code{\set} is left out, so automatic
1289 beaming is switched off in the current @rinternals{Voice}.  Note that
1290 the bottom-most context does not always contain the property that you
1291 wish to change -- for example, attempting to set the @code{skipBars}
1292 property (of the bottom-most context, in this case @code{Voice}) will
1293 have no effect.
1294
1295 @lilypond[quote,verbatim,relative=2,fragment]
1296 R1*2
1297 \set skipBars = ##t
1298 R1*2
1299 @end lilypond
1300
1301 Contexts are hierarchical, so if a bigger context was specified, for
1302 example @code{Staff}, then the change would also apply to all
1303 @code{Voice}s in the current stave.  The change is applied
1304 @q{on-the-fly}, during the music, so that the setting only affects the
1305 second group of eighth notes.
1306
1307 @funindex \unset
1308
1309 There is also an @code{\unset} command,
1310 @example
1311 \unset @var{context}.@var{prop}
1312 @end example
1313
1314 @noindent
1315 which removes the definition of @var{prop}.  This command removes
1316 the definition only if it is set in @var{context}, so
1317
1318 @example
1319 \set Staff.autoBeaming = ##f
1320 @end example
1321
1322 @noindent
1323 introduces a property setting at @code{Staff} level.  The setting also
1324 applies to the current @code{Voice}.  However,
1325
1326 @example
1327 \unset Voice.autoBeaming
1328 @end example
1329
1330 @noindent
1331 does not have any effect.  To cancel this setting, the @code{\unset}
1332 must be specified on the same level as the original @code{\set}.  In
1333 other words, undoing the effect of @code{Staff.autoBeaming = ##f}
1334 requires
1335 @example
1336 \unset Staff.autoBeaming
1337 @end example
1338
1339 Like @code{\set}, the @var{context} argument does not have to be
1340 specified for a bottom context, so the two statements
1341
1342 @example
1343 \set Voice.autoBeaming = ##t
1344 \set autoBeaming = ##t
1345 @end example
1346
1347 @noindent
1348 are equivalent.
1349
1350
1351 @cindex \once
1352 Settings that should only apply to a single time-step can be entered
1353 with @code{\once}, for example in
1354
1355 @lilypond[quote,verbatim,relative=2,fragment]
1356 c4
1357 \once \set fontSize = #4.7
1358 c4
1359 c4
1360 @end lilypond
1361
1362 the property @code{fontSize} is unset automatically after the second
1363 note.
1364
1365 A full description of all available context properties is in the
1366 program reference, see
1367 @ifhtml
1368 @rinternals{Tunable context properties}.
1369 @end ifhtml
1370 @ifnothtml
1371 Translation @expansion{} Tunable context properties.
1372 @end ifnothtml
1373
1374
1375
1376 @node The override command
1377 @subsection The @code{\override} command
1378
1379 Commands which change output generally look like
1380
1381 @example
1382 \override Voice.Stem #'thickness = #3.0
1383 @end example
1384
1385 @noindent
1386 To construct this tweak we must determine these bits of information:
1387
1388 @itemize
1389 @item the context: here @code{Voice}.
1390 @item the layout object: here @code{Stem}.
1391 @item the layout property: here @code{thickness}.
1392 @item a sensible value: here @code{3.0}.
1393 @end itemize
1394
1395 Some tweakable options are called @q{subproperties} and reside inside
1396 properties.  To tweak those, use commands in the form
1397
1398 @example
1399 \override Stem #'details #'beamed-lengths = #'(4 4 3)
1400 @end example
1401
1402 @cindex internal documentation
1403 @cindex finding graphical objects
1404 @cindex graphical object descriptions
1405 @cindex tweaking
1406 @funindex \override
1407 @cindex internal documentation
1408
1409 For many properties, regardless of the data type of the property, setting the
1410 property to false ( @code{##f} ) will result in turning it off, causing
1411 LilyPond to ignore that property entirely.  This is particularly useful for
1412 turning off grob properties which may otherwise be causing problems.
1413
1414 We demonstrate how to glean this information from the notation manual
1415 and the program reference.
1416
1417
1418 @node The tweak command
1419 @subsection The @code{\tweak} command
1420
1421 @funindex \tweak
1422 @cindex tweaking
1423
1424 In some cases, it is possible to take a short-cut for tuning
1425 graphical objects.  For objects that are created directly from
1426 an item in the input file, you can use the @code{\tweak} command.
1427 For example:
1428
1429 @lilypond[relative=2,verbatim]
1430 < c
1431   \tweak #'color #red
1432   d
1433   g
1434   \tweak #'duration-log #1
1435   a
1436 > 4
1437 -\tweak #'padding #8
1438 -^
1439 @end lilypond
1440
1441 @cindex chord, modifying one note in
1442
1443 But the main use of the @code{\tweak} command is to modify just
1444 one of a number of notation elements which start at the same musical
1445 moment, like the notes of a chord, or tuplet brackets which start
1446 at the same time.
1447
1448 For an introduction to the syntax and uses of the tweak command
1449 see @rlearning{Tweaking methods}.
1450
1451 The @code{\tweak} command sets a property in the following object
1452 directly, without requiring the grob name or context to be
1453 specified.  For this to work, it is necessary for the @code{\tweak}
1454 command to remain immediately adjacent to the object to which it is
1455 to apply after the input file has been converted to a music stream.
1456 This is often not the case, as many additional elements are inserted
1457 into the music stream implicitly.  For example, when a note which is
1458 not part of a chord is processed, Lilypond implicitly inserts a
1459 @code{ChordEvent} event before the note, so separating the tweak
1460 from the note.  However, if chord symbols are placed round the
1461 tweak and the note, the @code{\tweak} command comes after the
1462 @code{ChordEvent} in the music stream, so remaining adjacent to the
1463 note, and able to modify it.
1464
1465 So, this works:
1466
1467 @lilypond[relative=2,verbatim,quote]
1468 <\tweak #'color #red c>4
1469 @end lilypond
1470
1471 @noindent
1472 but this does not:
1473
1474 @lilypond[relative=2,verbatim,quote]
1475 \tweak #'color #red c4
1476 @end lilypond
1477
1478 When several similar items are placed at the same musical moment,
1479 the @code{\override} command cannot be used to modify just one of
1480 them -- this is where the @code{\tweak} command must be used.
1481 Items which may appear more than once at the same musical moment
1482 include the following:
1483
1484 @c TODO expand to include any further uses of \tweak
1485 @itemize
1486 @item note heads of notes inside a chord
1487 @item articulation signs on a single note
1488 @item ties between notes in a chord
1489 @item tuplet brackets starting at the same time
1490 @end itemize
1491
1492 @c TODO add examples of these
1493
1494 @noindent
1495 and @code{\tweak} may be used to modify any single occurrence of
1496 these items.
1497
1498 Notably the @code{\tweak} command cannot be used to modify stems,
1499 beams or accidentals, since these are generated later by note heads,
1500 rather than by music elements in the input stream.  Nor can a
1501 @code{\tweak} command be used to modify clefs or time signatures,
1502 since these become separated from any preceding @code{\tweak}
1503 command in the input stream by the automatic insertion of extra
1504 elements required to specify the context.
1505
1506 But the @code{\tweak} command can be used as an alternative to
1507 the @code{\override} command to modify those notational elements
1508 that do not cause any additional implicit elements to be added
1509 before them in the music stream.  For example, slurs may be
1510 modified in this way:
1511
1512 @lilypond[verbatim,quote,relative=1]
1513 c-\tweak #'thickness #5 ( d e f)
1514 @end lilypond
1515
1516 Also several @code{\tweak} commands may be placed before a
1517 notational element -- all affect it:
1518
1519 @lilypond[verbatim,quote,relative=1]
1520 c
1521 -\tweak #'style #'dashed-line
1522 -\tweak #'dash-fraction #0.2
1523 -\tweak #'thickness #3
1524 -\tweak #'color #red
1525  \glissando
1526 f'
1527 @end lilypond
1528
1529 The music stream which is generated from a section of an input file,
1530 including any automatically inserted elements, may be examined,
1531 see @ref{Displaying music expressions}.  This may be helpful in
1532 determining what may be modified by a @code{\tweak} command.
1533
1534 @seealso
1535
1536 Learning Manual:
1537 @rlearning{Tweaking methods}.
1538
1539 Notation Reference:
1540 @ref{Displaying music expressions}.
1541
1542 @knownissues
1543
1544 @cindex tweaks in a variable
1545 The @code{\tweak} command cannot be used inside a variable.
1546
1547 @cindex tweaks in lyrics
1548 The @code{\tweak} commands cannot be used in @code{\lyricmode}.
1549
1550 @cindex tweaking control points
1551 @cindex control points, tweaking
1552
1553 The @code{\tweak} command cannot be used to modify the control
1554 points of just one of several ties in a chord, other than the first
1555 one encountered in the input file.
1556
1557 @node set versus override
1558 @subsection @code{\set} vs. @code{\override}
1559
1560 We have seen two methods of changing properties: @code{\set} and
1561 @code{\override}.  There are actually two different kinds of
1562 properties.
1563
1564 Contexts can have properties, which are usually named in
1565 @code{studlyCaps}.  They mostly control the translation from
1566 music to notation, eg. @code{localKeySignature} (for determining
1567 whether to print accidentals), @code{measurePosition} (for
1568 determining when to print a bar line).  Context properties can
1569 change value over time while interpreting a piece of music;
1570 @code{measurePosition} is an obvious example of
1571 this.  Context properties are modified with @code{\set}.
1572
1573 There is a special type of context property: the element
1574 description.  These properties are named in @code{StudlyCaps}
1575 (starting with capital letters).  They contain the
1576 @q{default settings} for said graphical object as an
1577 association list.  See @file{scm/@/define@/-grobs@/.scm}
1578 to see what kind of settings there are.  Element descriptions
1579 may be modified with @code{\override}.
1580
1581 @code{\override} is actually a shorthand;
1582
1583 @example
1584 \override @var{context}.@var{name} #'@var{property} = #@var{value}
1585 @end example
1586
1587 @noindent
1588 is more or less equivalent to
1589
1590 @c  leave this long line -gp
1591 @example
1592 \set @var{context}.@var{name} #'@var{property} = #(cons (cons '@var{property} @var{value}) <previous value of @var{context})
1593 @end example
1594
1595 The value of @code{context} (the alist) is used to initialize
1596 the properties of individual grobs.  Grobs also have
1597 properties, named in Scheme style, with
1598 @code{dashed-words}.  The values of grob properties change
1599 during the formatting process: formatting basically amounts
1600 to computing properties using callback functions.
1601
1602 @code{fontSize} is a special property: it is equivalent to
1603 entering @code{\override ... #'font-size} for all pertinent
1604 objects.  Since this is a common change, the special
1605 property (modified with @code{\set}) was created.
1606
1607
1608 @node Useful concepts and properties
1609 @section Useful concepts and properties
1610
1611
1612 @menu
1613 * Input modes::
1614 * Direction and placement::
1615 * Distances and measurements::
1616 * Spanners::
1617 @end menu
1618
1619 @node Input modes
1620 @subsection Input modes
1621
1622 The way in which the notation contained within an input file is
1623 interpreted is determined by the current input mode.
1624
1625 @strong{Chord mode}
1626
1627 This is activated with the @code{\chordmode} command, and causes
1628 input to be interpreted with the syntax of chord notation, see
1629 @ref{Chord notation}.  Chords are rendered as notes on a staff.
1630
1631 Chord mode is also activated with the @code{\chords} command.
1632 This also creates a new @code{ChordNames} context and
1633 causes the following input to be interpreted with the syntax of
1634 chord notation and rendered as chord names in the @code{ChordNames}
1635 context, see @ref{Printing chord names}.
1636
1637 @strong{Drum mode}
1638
1639 This is activated with the @code{\drummode} command, and causes
1640 input to be interpreted with the syntax of drum notation, see
1641 @ref{Basic percussion notation}.
1642
1643 Drum mode is also activated with the @code{\drums} command.
1644 This also creates a new @code{DrumStaff} context and causes the
1645 following input to be interpreted with the syntax of drum notation
1646 and rendered as drum symbols on a drum staff, see @ref{Basic
1647 percussion notation}.
1648
1649 @strong{Figure mode}
1650
1651 This is activated with the @code{\figuremode} command, and causes
1652 input to be interpreted with the syntax of figured bass, see
1653 @ref{Entering figured bass}.
1654
1655 Figure mode is also activated with the @code{\figures} command.
1656 This also creates a new @code{FiguredBass} context and causes the
1657 following input to be interpreted with the figured bass syntax
1658 and rendered as figured bass symbols in the @code{FiguredBass}
1659 context, see @ref{Introduction to figured bass}.
1660
1661 @strong{Fret and tab modes}
1662
1663 There are no special input modes for entering fret and tab symbols.
1664
1665 To create tab diagrams, enter notes or chords in note mode and
1666 render them in a @code{TabStaff} context, see
1667 @ref{Default tablatures}.
1668
1669 To create fret diagrams above a staff, you have two choices.
1670 You can either use the @code{FretBoards} context (see
1671 @ref{Automatic fret diagrams} or you can enter them as a markup
1672 above the notes using the @code{\fret-diagram} command (see
1673 @ref{Fret diagram markups}).
1674
1675 @strong{Lyrics mode}
1676
1677 This is activated with the @code{\lyricmode} command, and causes
1678 input to be interpreted as lyric syllables with optional durations
1679 and associated lyric modifiers, see @ref{Vocal music}.
1680
1681 Lyric mode is also activated with the @code{\addlyrics} command.
1682 This also creates a new @code{Lyrics} context and an implicit
1683 @code{\lyricsto} command which associates the following lyrics
1684 with the preceding music.
1685
1686 @strong{Markup mode}
1687
1688 This is activated with the @code{\markup} command, and causes
1689 input to be interpreted with the syntax of markup, see
1690 @ref{Text markup commands}.
1691
1692 @c silly work-around for texinfo broken-ness
1693 @c (@strong{Note...} causes a spurious cross-reference in Info)
1694 @b{Note mode}
1695
1696 This is the default mode or it may be activated with the
1697 @code{\notemode} command.  Input is interpreted as pitches,
1698 durations, markup, etc and typeset as musical notation on a staff.
1699
1700 It is not normally necessary to specify note mode explicitly, but
1701 it may be useful to do so in certain situations, for example if you
1702 are in lyric mode, chord mode or any other mode and want to insert
1703 something that only can be done with note mode syntax.
1704
1705 For example, to indicate dynamic markings for the verses of a
1706 choral pieces it is necessary to enter note mode to interpret
1707 the markings:
1708
1709 @lilypond[verbatim,relative=2,quote]
1710 { c4 c4 c4 c4 }
1711 \addlyrics {
1712   \notemode{\set stanza = \markup{ \dynamic f 1. } }
1713   To be sung loudly
1714 }
1715 \addlyrics {
1716   \notemode{\set stanza = \markup{ \dynamic p 2. } }
1717   To be sung quietly
1718 }
1719 @end lilypond
1720
1721
1722
1723 @node Direction and placement
1724 @subsection Direction and placement
1725
1726 In typesetting music the direction and placement of many items is
1727 a matter of choice.  For example, the stems of notes can
1728 be directed up or down; lyrics, dynamics, and other expressive
1729 marks may be placed above or below the staff; text may be aligned
1730 left, right or center; etc.  Most of these choices may be left to
1731 be determined automatically by LilyPond, but in some cases it may
1732 be desirable to force a particular direction or placement.
1733
1734 @strong{Default actions}
1735
1736 By default some directions are always up or always down (e.g.
1737 dynamics or fermata), while other things can alternate between
1738 up or down based on the stem direction (like slurs or accents).
1739
1740 @c TODO Add table showing these
1741
1742 @strong{Context layout}
1743
1744 Contexts are positioned in a system from top to bottom in the
1745 order in which they are encountered.  Note, however, that a
1746 context will be created implicitly if a command is encountered
1747 when there is no suitable context available to contain it.
1748
1749 @c TODO Add example ?
1750
1751 The default order in which contexts are laid out can be changed,
1752 see @ref{Aligning contexts}
1753
1754 @strong{Articulation direction indicators}
1755
1756 When adding articulations to notes the direction indicator,
1757 @code{^} (meaning @qq{up}), @code{_} (meaning @qq{down}) or
1758 @code{-} (meaning @qq{use default direction}), can usually be
1759 omitted, in which case @code{-} is assumed.  But a direction
1760 indicator is @strong{always} required before
1761
1762 @itemize
1763 @item @code{\tweak} commands
1764 @item @code{\markup} commands
1765 @item @code{\tag} commands
1766 @item string markups, e.g. -"string"
1767 @item fingering instructions, e.g. @code{-1}
1768 @item articulation shortcuts, e.g. @code{-.}, @code{->}, @code{--}
1769 @end itemize
1770
1771 @strong{The direction property}
1772
1773 The position or direction of many layout objects is controlled
1774 by the @code{direction} property.
1775
1776 The value of the @code{direction} property may be
1777 set to @code{1}, meaning @qq{up} or @qq{above}, or to @code{-1},
1778 meaning @qq{down} or @qq{below}.  The symbols @code{UP} and
1779 @code{DOWN} may be used instead of @code{1} and @code{-1}
1780 respectively.  The default direction may be specified by setting
1781 @code{direction} to @code{0} or @code{CENTER}.  Alternatively,
1782 in many cases predefined commands
1783 exist to specify the direction.  These are all of the form
1784
1785 @noindent
1786 @code{\xxxUp}, @code{xxxDown}, @code{xxxNeutral}
1787
1788 @noindent
1789 where @code{xxxNeutral} means @qq{use the default direction}.
1790 See @rlearning{Within-staff objects}.
1791
1792 In a few cases, arpeggio being the only common example, the value
1793 of the @code{direction} property specifies whether the object
1794 is to be placed to the right or left of the parent object.  In
1795 this case @code{-1} or @code{LEFT} means @qq{to the left} and
1796 @code{1} or @code{RIGHT} means @qq{to the right}.  @code{0}
1797 or @code{CENTER} means @qq{use the default} direction, as before.
1798
1799 @ignore
1800 These all have side-axis set to #X
1801 AmbitusAccidental - direction has no effect
1802 Arpeggio - works
1803 StanzaNumber - not tried
1804 TrillPitchAccidental - not tried
1805 TrillPitchGroup - not tried
1806 @end ignore
1807
1808
1809
1810 @node Distances and measurements
1811 @subsection Distances and measurements
1812
1813 DISCUSS after working on other sections.
1814
1815 TODO: staff spaces.  Maybe move into tweaks?
1816
1817
1818 @node Spanners
1819 @subsection Spanners
1820
1821 Many objects of musical notation extend over several notes or even
1822 several bars.  Examples are crescendi, trills, tuplet brackets, and
1823 volta repeat brackets.  Such objects are called @qq{spanners}, and
1824 have special properties to control their appearance and behaviour.
1825 Some of these properties are common to all spanners; others are
1826 restricted to a sub-set of the spanners.
1827
1828 @node Common properties
1829 @section Common properties
1830
1831 @menu
1832 * Controlling visibility of objects::  
1833 * Line styles::                 
1834 * Rotating objects::            
1835 * Aligning objects::            
1836 @end menu
1837
1838 @node Controlling visibility of objects
1839 @subsection Controlling visibility of objects
1840
1841 @cindex objects, visibility of
1842 @cindex grobs, visibility of
1843 @cindex visibility of objects
1844
1845 There are four main ways in which the visibility of layout objects
1846 can be controlled: their stencil can be removed, they can be made
1847 transparent, they can be colored white, or their
1848 @code{break-visibility} property can be overridden.  The first
1849 three apply to all layout objects; the last to just a few -- the
1850 @emph{breakable} objects.  The Learning Manual introduces these
1851 four techniques, see @rlearning{Visibility and color of objects}.
1852
1853 There are also a few other techniques which are specific to
1854 certain layout objects.  These are covered under Special
1855 considerations.
1856
1857 @menu
1858 * Removing the stencil::        
1859 * Making objects transparent::  
1860 * Painting objects white::      
1861 * Using break-visibility::      
1862 * Special considerations::      
1863 @end menu
1864
1865
1866 @node Removing the stencil
1867 @unnumberedsubsubsec Removing the stencil
1868
1869 @cindex stencil, removing
1870
1871 Every layout object has a stencil property.  By default this is set
1872 to the specific function which draws that object.  If this property
1873 is overridden to @code{#f} no function will be called and the object
1874 will not be drawn.  The default action can be recovered with
1875 @code{\revert}.
1876
1877 @lilypond[quote,verbatim,relative=1]
1878 a1 a
1879 \override Score.BarLine #'stencil = ##f
1880 a a
1881 \revert Score.BarLine #'stencil
1882 a a a
1883 @end lilypond
1884
1885 @node Making objects transparent
1886 @unnumberedsubsubsec Making objects transparent
1887
1888 @cindex transparent, making objects
1889
1890 Every layout object has a transparent property which by default is
1891 set to @code{#f}.  If set to @code{#t} the object still occupies
1892 space but is made invisible.
1893
1894 @lilypond[quote,verbatim,relative=2]
1895 a4 a
1896 \once \override NoteHead #'transparent = ##t
1897 a a
1898 @end lilypond
1899
1900 @node Painting objects white
1901 @unnumberedsubsubsec Painting objects white
1902
1903 @cindex objects, coloring
1904 @cindex coloring objects
1905 @cindex layers
1906 @cindex printing order
1907 @cindex overwriting objects
1908 @cindex objects, overwriting
1909 @cindex grobs, overwriting
1910
1911 Every layout object has a color property which by default is set
1912 to @code{black}.  If this is overridden to @code{white} the object
1913 will be indistinguishable from the white background.  However,
1914 if the object crosses other objects the color of the crossing
1915 points will be determined by the order in which they are drawn,
1916 and this may leave a ghostly image of the white object, as shown
1917 here:
1918
1919 @lilypond[quote,verbatim,relative=2]
1920 \override Staff.Clef #'color = #white
1921 a1
1922 @end lilypond
1923
1924 This may be avoided by changing the order of printing the objects.
1925 All layout objects have a @code{layer} property which should be set
1926 to an integer.  Objects with the lowest value of @code{layer} are
1927 drawn first, then objects with progressively higher values are drawn,
1928 so objects with higher values overwrite objects with lower values.
1929 By default most objects are assigned a @code{layer} value of
1930 @code{1}, although a few objects, including @code{StaffSymbol} and
1931 @code{BarLine}, are assigned a value of @code{0}.  The order of
1932 printing objects with the same value of @code{layer} is indeterminate.
1933
1934 In the example above the white clef, with a default @code{layer}
1935 value of @code{1}, is drawn after the staff lines (default
1936 @code{layer} value @code{0}), so overwriting them.  To change this,
1937 the @code{Clef} object must be given in a lower value of
1938 @code{layer}, say @code{-1}, so that it is drawn earlier:
1939
1940 @lilypond[quote,verbatim,relative=2]
1941 \override Staff.Clef #'color = #white
1942 \override Staff.Clef #'layer = #-1
1943 a1
1944 @end lilypond
1945
1946 @node Using break-visibility
1947 @unnumberedsubsubsec Using break-visibility
1948
1949 @c TODO Add making other objects breakable
1950
1951 @cindex break-visibility
1952
1953 Most layout objects are printed only once, but some like
1954 bar lines, clefs, time signatures and key signatures, may need
1955 to be printed twice when a line break occurs -- once at the end
1956 of the line and again at the start of the next line.  Such
1957 objects are called @emph{breakable}, and have a property, the
1958 @code{break-visibility} property to control their visibility
1959 at the three positions in which they may appear -- at the
1960 start of a line, within a line if they are changed, and at the
1961 end of a line if a change takes place there.
1962
1963 For example, the time signature
1964 by default will be printed at the start of the first line, but
1965 nowhere else unless it changes, when it will be printed at the
1966 point at which the change occurs.  If this change occurs at the
1967 end of a line the new time signature will be printed at the start
1968 of the next line and a cautionary time signature will be printed
1969 at the end of the previous line as well.
1970
1971 This behaviour is controlled by the @code{break-visibility}
1972 property, which is explained in
1973 @c Leave this ref on a newline - formats incorrectly otherwise -td
1974 @rlearning{Visibility and color of objects}.  This property takes
1975 a vector of three booleans which, in order, determine whether the
1976 object is printed at the end of, within the body of, or at the
1977 beginning of a line.  Or to be more precise, before a line break,
1978 where there is no line break, or after a line break.
1979
1980 Alternatively, seven of the eight combinations may be specified
1981 by pre-defined functions, defined in @file{scm/output-lib.scm},
1982 where the last three columns indicate whether the layout objects
1983 will be visible in the positions shown at the head of the columns:
1984
1985 @multitable @columnfractions .40 .15 .1 .1 .1
1986 @c TODO check these more carefully
1987 @headitem Function                   @tab Vector                  @tab Before @tab At no    @tab After
1988 @headitem form                       @tab form                    @tab break  @tab break    @tab break
1989
1990 @item @code{all-invisible}           @tab @code{'#(#f #f #f)} @ @ @tab no     @tab no       @tab no
1991 @item @code{begin-of-line-visible}   @tab @code{'#(#f #f #t)}     @tab no     @tab no       @tab yes
1992 @item @code{end-of-line-visible}     @tab @code{'#(#t #f #f)}     @tab yes    @tab no       @tab no
1993 @item @code{all-visible}             @tab @code{'#(#t #t #t)}     @tab yes    @tab yes      @tab yes
1994 @c The center-visible function is not defined
1995 @c @item @code{center-visible}       @tab @code{'#(#f #t #f)}     @tab no     @tab yes      @tab no
1996 @item @code{begin-of-line-invisible} @tab @code{'#(#t #t #f)}     @tab yes    @tab yes      @tab no
1997 @item @code{end-of-line-invisible}   @tab @code{'#(#f #t #t)}     @tab no     @tab yes      @tab yes
1998 @item @code{center-invisible}        @tab @code{'#(#t #f #t)}     @tab yes    @tab no       @tab yes
1999 @end multitable
2000
2001 The @code{center-visible} function is not pre-defined.
2002
2003 The default settings of @code{break-visibility} depend on the
2004 layout object.  The following table shows all the layout objects
2005 of interest which are affected by @code{break-visibility} and the
2006 default setting of this property:
2007
2008 @multitable @columnfractions .3 .3 .4
2009
2010 @headitem Layout object   @tab Usual context  @tab Default setting
2011
2012 @c omit Ambitus as it appears not to be affected by break-visibility -td
2013 @c @item @code{Ambitus}          @tab as specified   @tab @code{begin-of-line-visible}
2014 @item @code{BarLine}             @tab @code{Score}          @tab calculated
2015 @item @code{BarNumber}           @tab @code{Score}          @tab @code{begin-of-line-visible}
2016 @c omit the following item until it can be explained -td
2017 @c @item @code{BreakAlignGroup}  @tab @code{Score}          @tab calculated
2018 @item @code{BreathingSign}       @tab @code{Voice}          @tab @code{begin-of-line-invisible}
2019 @item @code{Clef}                @tab @code{Staff}          @tab @code{begin-of-line-visible}
2020 @item @code{Custos}              @tab @code{Staff}          @tab @code{end-of-line-visible}
2021 @item @code{DoublePercentRepeat} @tab @code{Voice}          @tab @code{begin-of-line-invisible}
2022 @c omit KeyCancellation until it can be explained -td
2023 @c @item @code{KeyCancellation}  @tab ??             @tab @code{begin-of-line-invisible}
2024 @item @code{KeySignature}        @tab @code{Staff}          @tab @code{begin-of-line-visible}
2025 @c omit LeftEdge until it can be explained -td
2026 @c @item @code{LeftEdge}         @tab @code{Score}          @tab @code{center-invisible}
2027 @item @code{OctavateEight}       @tab @code{Staff}          @tab @code{begin-of-line-visible}
2028 @item @code{RehearsalMark}       @tab @code{Score}          @tab @code{end-of-line-invisible}
2029 @item @code{TimeSignature}       @tab @code{Staff}          @tab @code{all-visible}
2030
2031 @end multitable
2032
2033 The example below shows the use of the vector form to control the
2034 visibility of barlines:
2035
2036 @lilypond[quote,verbatim,relative=1,ragged-right]
2037 f4 g a b
2038 f4 g a b
2039 % Remove bar line at the end of the current line
2040 \once \override Score.BarLine #'break-visibility = #'#(#f #t #t)
2041 \break
2042 f4 g a b
2043 f4 g a b
2044 @end lilypond
2045
2046 Although all three components of the vector used to override
2047 @code{break-visibility} must be present, not all of them are
2048 effective with every layout object, and some combinations may
2049 even give errors.  The following limitations apply:
2050
2051 @itemize @bullet
2052 @item Bar lines cannot be printed at start of line.
2053 @item A bar number cannot be printed at the start of the first
2054 line unless it is set to be different from 1.
2055 @item Clef -- see below
2056 @item Double percent repeats are either all printed or all
2057 suppressed.  Use begin-of line-invisible to print and
2058 all-invisible to suppress.
2059 @item Key signature -- see below
2060 @item OctavateEight -- see below
2061 @end itemize
2062
2063 @node Special considerations
2064 @unnumberedsubsubsec Special considerations
2065
2066 @strong{@emph{Visibility following explicit changes}}
2067
2068 @cindex key signature, visibility following explicit change
2069 @cindex explicitKeySignatureVisibility
2070 @cindex clef, visibility following explicit change
2071 @cindex explicitClefVisibility
2072
2073 The @code{break-visibility} property controls the visibility of
2074 key signatures and changes of clef only at the start of lines,
2075 i.e. after a break.  It has no effect on the visibility of the
2076 key signature or clef following an explicit key change or an
2077 explicit clef change within or at the end of a line.  In the
2078 following example the key signature following the explicit change
2079 to B-flat major is still visible, even though @code{all-invisible}
2080 is set.
2081
2082 @lilypond[quote,verbatim,relative=1,ragged-right]
2083 \key g \major
2084 f4 g a b
2085 % Try to remove all key signatures
2086 \override Staff.KeySignature #'break-visibility = #all-invisible
2087 \key bes \major
2088 f4 g a b
2089 \break
2090 f4 g a b
2091 f4 g a b
2092 @end lilypond
2093
2094 The visibility of such explicit key signature and clef changes is
2095 controlled by the @code{explicitKeySignatureVisibility} and
2096 @code{explicitClefVisibility} properties.  These are the equivalent
2097 of the @code{break-visibility} property and both take a vector of
2098 three booleans or the predefined functions listed above, exactly like
2099 @code{break-visibility}.  Both are properties of the Staff context,
2100 not the layout objects themselves, and so they are set using the
2101 @code{\set} command.  Both are set by default to @code{all-visible}.
2102 These properties control only the visibility of key signatures and
2103 clefs resulting from explicit changes and do not affect key
2104 signatures and clefs at the beginning of lines;
2105 @code{break-visibility} must still be overridden in the appropriate
2106 object to remove these.
2107
2108 @lilypond[quote,verbatim,relative=1,ragged-right]
2109 \key g \major
2110 f4 g a b
2111 \set Staff.explicitKeySignatureVisibility = #all-invisible
2112 \override Staff.KeySignature #'break-visibility = #all-invisible
2113 \key bes \major
2114 f4 g a b \break
2115 f4 g a b
2116 f4 g a b
2117 @end lilypond
2118
2119 @strong{@emph{Visibility of cautionary accidentals}}
2120
2121 To remove the cautionary accidentals printed at an explicit key
2122 change, set the Staff context property @code{printKeyCancellation}
2123 to @code{#f}:
2124
2125 @lilypond[quote,verbatim,relative=1,ragged-right]
2126 \key g \major
2127 f4 g a b
2128 \set Staff.explicitKeySignatureVisibility = #all-invisible
2129 \set Staff.printKeyCancellation = ##f
2130 \override Staff.KeySignature #'break-visibility = #all-invisible
2131 \key bes \major
2132 f4 g a b \break
2133 f4 g a b
2134 f4 g a b
2135 @end lilypond
2136
2137 With these overrides only the accidentals before the notes remain
2138 to indicate the change of key.
2139
2140 @c TODO Add visibility of cautionary accidentals before notes
2141
2142 @strong{@emph{Automatic bars}}
2143
2144 @cindex automaticBars
2145 @cindex bar lines, suppressing
2146
2147 As a special case, the printing of bar lines can also be turned off
2148 by setting the @code{automaticBars} property in the Score context.
2149 If set to @code{#f}, bar lines will not be printed automatically;
2150 they must be explicitly created with a @code{\bar} command.  Unlike
2151 the @code{\cadenzaOn} predefined command, measures are still counted.
2152 Bar generation will resume according to that count if this property
2153 is later set to @code{#t}.  When set to @code{#f}, line breaks can
2154 occur only at explicit @code{\bar} commands.
2155
2156 @c TODO Add example
2157
2158 @strong{@emph{Octavated clefs}}
2159
2160 @cindex octavated clefs, visibility of
2161 @cindex visibility of octavated clefs
2162 @cindex clefs, visibility of octavation
2163
2164 The small octavation symbol on octavated clefs is produced by the
2165 @code{OctavateEight} layout object.  Its visibility is controlled
2166 independently from that of the @code{Clef} object, so it is
2167 necessary to apply any required @code{break-visibility} overrides
2168 to both the @code{Clef} and the @code{OctavateEight} layout objects
2169 to fully suppress such clef symbols at the start of each line.
2170
2171 For explicit clef changes, the @code{explicitClefVisibility}
2172 property controls both the clef symbol and any octavation symbol
2173 associated with it.
2174
2175
2176 @seealso
2177 Learning Manual:
2178 @rlearning{Visibility and color of objects}
2179
2180
2181 @node Line styles
2182 @subsection Line styles
2183
2184 @c TODO: split the following explanations between expressive marks and
2185 @c text-related stuff. Perhaps create a new subsection named
2186 @c "Spanner limits", "Spanner boundaries"? -vv
2187
2188 Some performance indications, e.g., @i{rallentando} and
2189 @i{accelerando} and @i{trills} are written as text and are
2190 extended over many measures with lines, sometimes dotted or wavy.
2191
2192 These all use the same routines as the glissando for drawing the
2193 texts and the lines, and tuning their behavior is therefore also
2194 done in the same way.  It is done with a spanner, and the routine
2195 responsible for drawing the spanners is
2196 @code{ly:line-interface::print}.  This routine determines the
2197 exact location of the two @i{span points} and draws a line in
2198 between, in the style requested.
2199
2200 Here is an example of the different line styles available, and how
2201 to tune them.
2202
2203 @lilypond[relative=2,ragged-right,verbatim,fragment]
2204 d2 \glissando d'2
2205 \once \override Glissando #'style = #'dashed-line
2206 d,2 \glissando d'2
2207 \override Glissando #'style = #'dotted-line
2208 d,2 \glissando d'2
2209 \override Glissando #'style = #'zigzag
2210 d,2 \glissando d'2
2211 \override Glissando #'style = #'trill
2212 d,2 \glissando d'2
2213 @end lilypond
2214
2215 The information that determines the end-points is computed
2216 on-the-fly for every graphic object, but it is possible to
2217 override these.
2218
2219 @lilypond[relative=2,ragged-right,verbatim,fragment]
2220 e2 \glissando f
2221 \once \override Glissando #'bound-details #'right #'Y = #-2
2222 e2 \glissando f
2223 @end lilypond
2224
2225 The @code{Glissando} object, like any other using the
2226 @code{ly:line-interface::print} routine, carries a nested
2227 association list.  In the above statement, the value for @code{Y}
2228 is set to @code{-2} for the association list corresponding to the
2229 right end point.  Of course, it is also possible to adjust the
2230 left side with @code{left} instead of @code{right}.
2231
2232 If @code{Y} is not set, the value is computed from the vertical
2233 position of right attachment point of the spanner.
2234
2235 In case of a line break, the values for the span-points are
2236 extended with contents of the @code{left-broken} and
2237 @code{right-broken} sublists, for example
2238
2239 @lilypond[relative=2,ragged-right,verbatim,fragment]
2240 \override Glissando #'breakable = ##T
2241 \override Glissando #'bound-details #'right-broken #'Y = #-3
2242 c1 \glissando \break
2243 f1
2244 @end lilypond
2245
2246 The following properties can be used for the
2247
2248 @table @code
2249 @item Y
2250 This sets the Y-coordinate of the end point, in staff space.  By
2251 default, it is the center of the bound object, so for a glissando
2252 it points to the vertical center of the note head.
2253
2254 For horizontal spanners, such as text spanner and trill spanners,
2255 it is hardcoded to 0.
2256
2257 @item attach-dir
2258 This determines where the line starts and ends in X-direction,
2259 relative to the bound object.  So, a value of @code{-1} (or
2260 @code{LEFT}) makes the line start/end at the left side of the note
2261 head it is attached to.
2262
2263 @item X
2264 This is the absolute coordinate of the end point.  It is usually
2265 computed on the fly, and there is little use in overriding it.
2266
2267 @item stencil
2268 Line spanners may have symbols at the beginning or end, which is
2269 contained in this sub-property.  This is for internal use, it is
2270 recommended to use @code{text}.
2271
2272 @item text
2273 This is a markup that is evaluated to yield stencil.  It is used
2274 to put @i{cresc.} and @i{tr} on horizontal spanners.
2275
2276 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
2277 \override TextSpanner #'bound-details #'left #'text
2278    = \markup { \small \bold Slower }
2279 c2\startTextSpan b c a\stopTextSpan
2280 @end lilypond
2281
2282 @item stencil-align-dir-y
2283 @item stencil-offset
2284 Without setting this, the stencil is simply put there at the
2285 end-point, as defined by the @code{X} and @code{Y} sub properties.
2286 Setting either @code{stencil-align-dir-y} or @code{stencil-offset}
2287 will move the symbol at the edge relative to the end point of the
2288 line
2289
2290 @lilypond[relative=1,fragment,verbatim]
2291 \override TextSpanner #'bound-details
2292   #'left #'stencil-align-dir-y = #DOWN
2293 \override TextSpanner #'bound-details
2294   #'right #'stencil-align-dir-y = #UP
2295
2296 \override TextSpanner #'bound-details
2297   #'left #'text = #"gggg"
2298 \override TextSpanner #'bound-details
2299   #'right #'text = #"hhhh"
2300 c4^\startTextSpan c c c \stopTextSpan
2301 @end lilypond
2302
2303 @item arrow
2304 Setting this sub property to @code{#t} produce an arrowhead at the
2305 end of the line.
2306
2307 @item padding
2308 This sub property controls the space between the specified
2309 end-point of the line and the actual end.  Without padding, a
2310 glissando would start and end in the center of each note head.
2311
2312 @end table
2313
2314 @c TODO: Move to 5.4.4
2315
2316 The music function \endSpanners terminates spanners and hairpins
2317 after exactly one note.
2318
2319 @lilypond[verbatim,quote,ragged-right,relative=2,fragment]
2320 \endSpanners
2321 c2 \startTextSpan c2
2322 c2 \< c2
2323 @end lilypond
2324
2325 When using \endSpanners it is not necessary to close
2326 \startTextSpan with \stopTextSpan, nor is it necessary to close
2327 hairpins with \!.
2328
2329
2330
2331 @seealso
2332
2333 Internals Reference: @rinternals{TextSpanner},
2334 @rinternals{Glissando}, @rinternals{VoiceFollower},
2335 @rinternals{TrillSpanner},
2336 @rinternals{line-spanner-interface}.
2337
2338
2339 @node Rotating objects
2340 @subsection Rotating objects
2341
2342 Both layout objects and elements of markup text can be rotated by
2343 any angle about any point, but the method of doing so differs.
2344
2345 @menu
2346 * Rotating layout objects::     
2347 * Rotating markup::             
2348 @end menu
2349
2350 @node Rotating layout objects
2351 @unnumberedsubsubsec Rotating layout objects
2352
2353 @cindex rotating objects
2354 @cindex objects, rotating
2355
2356 All layout objects which support the @code{grob-interface} can be
2357 rotated by setting their @code{rotation} property.  This takes a
2358 list of three items: the angle of rotation counter-clockwise,
2359 and the x and y coordinates of the point relative to the object's
2360 reference point about which the rotation is to be performed.  The
2361 angle of rotation is specified in degrees and the coordinates in
2362 staff-spaces.
2363
2364 The angle of rotation and the coordinates of the rotation point must
2365 be determined by trial and error.
2366
2367 @cindex hairpins, angled
2368 @cindex angled hairpins
2369
2370 There are only a few situations where the rotation of layout
2371 objects is useful; the following example shows one situation where
2372 they may be:
2373
2374 @lilypond[quote,verbatim,relative=1]
2375 g4\< e' d' f\!
2376 \override Hairpin #'rotation = #'(20 -1 0)
2377 g,,4\< e' d' f\!
2378 @end lilypond
2379
2380 @node Rotating markup
2381 @unnumberedsubsubsec Rotating markup
2382
2383 All markup text can be rotated to lie at any angle by prefixing it
2384 with the @code{\rotate} command.  The command takes two arguments:
2385 the angle of rotation in degrees counter-clockwise and the text to
2386 be rotated.  The extents of the text are not rotated: they take
2387 their values from the extremes of the x and y coordinates of the
2388 rotated text.  In the following example the
2389 @code{outside-staff-priority} property for text is set to @code{#f}
2390 to disable the automatic collision avoidance, which would push some
2391 of the text too high.
2392
2393 @lilypond[quote,verbatim,relative=1]
2394 \override TextScript #'outside-staff-priority = ##f
2395 g4^\markup { \rotate #30 "a G" }
2396 b^\markup { \rotate #30 "a B" }
2397 des^\markup { \rotate #30 "a D-Flat" }
2398 fis^\markup { \rotate #30 "an F-Sharp" }
2399 @end lilypond
2400
2401
2402 @node Aligning objects
2403 @subsection Aligning objects
2404
2405 Graphical objects which support the @code{self-alignment-interface} and/or
2406 the @code{side-position-interface} can be
2407 aligned to a previously placed object in a variety of ways.  For a list of these objects, see
2408 @rinternals{self-alignment-interface} and @rinternals{side-position-interface}.
2409
2410 All graphical objects have a reference point, a horizontal extent and a
2411 vertical extent.  The horizontal extent is a pair of numbers
2412 giving the displacements from the reference point of the left and
2413 right edges, displacements to the left being negative.  The
2414 vertical extent is a pair of numbers giving the displacement from
2415 the reference point to the bottom and top edges, displacements down
2416 being negative.
2417
2418 An object's position on a staff is given by the values of the
2419 @code{X-offset} and @code{Y-offset} properties.  The value of
2420 @code{X-offset} gives the displacement from the x coordinate of
2421 the reference point of the parent object, and the value of
2422 @code{Y-offset} gives the displacement from the center line of the
2423 staff.   The values of @code{X-offset} and
2424 @code{Y-offset} may be set directly or may be set to be calculated
2425 by procedures in order to achieve alignment with the parent object
2426 in several ways.
2427
2428 @warning{Many objects have special positioning considerations which
2429 cause any setting of @code{X-offset} or @code{Y-offset} to be
2430 ignored or modified, even though the object supports the
2431 @code{self-alignment-interface}.}
2432
2433 For example, an accidental can be repositioned
2434 vertically by setting @code{Y-offset} but any changes to
2435 @code{X-offset} have no effect.
2436
2437 Rehearsal marks may be aligned with
2438 breakable objects such as bar lines, clef symbols, time signature
2439 symbols and key signatures.  There are special properties to be
2440 found in the @code{break-aligned-interface} for positioning rehearsal
2441 marks on such objects.
2442
2443 @menu
2444 * Setting @code{X-offset} and @code{Y-offset} directly::
2445 * Using the @code{side-position-interface}::
2446 * Using the @code{self-alignment-interface}::
2447 * Using the @code{break-aligned-interface}::
2448 @end menu
2449
2450 @node Setting @code{X-offset} and @code{Y-offset} directly
2451 @unnumberedsubsubsec Setting @code{X-offset} and @code{Y-offset} directly
2452
2453 Numerical values may be given to the @code{X-offset} and @code{Y-offset}
2454 properties of many objects.  The following example shows three
2455 notes with the default fingering position and the positions with @code{X-offset}
2456 and @code{Y-offset} modified.
2457
2458 @lilypond[verbatim,quote,relative=2]
2459 a-3
2460 a
2461 -\tweak #'X-offset #0
2462 -\tweak #'Y-offset #0
2463 -3
2464 a
2465 -\tweak #'X-offset #-1
2466 -\tweak #'Y-offset #1
2467 -3
2468 @end lilypond
2469
2470 @c TODO write more
2471
2472 @node Using the @code{side-position-interface}
2473 @unnumberedsubsubsec Using the @code{side-position-interface}
2474
2475 An object which supports the @code{side-position-interface} can be
2476 placed next to its parent object so that
2477 the specified edges of the two objects touch.  The object may be
2478 placed above, below, to the right or to the left of the parent.
2479 The parent cannot be specified; it is determined by the order of
2480 elements in the input stream.  Most objects have the associated
2481 note head as their parent.
2482
2483 The values of the @code{side-axis} and @code{direction} properties
2484 determine where the object is to be placed, as follows:
2485
2486 @c TODO add an example of each to the table
2487
2488 @multitable @columnfractions .3 .3 .3
2489 @headitem @code{side-axis}  @tab @code{direction}  @tab
2490 @headitem property          @tab property          @tab Placement
2491
2492 @item     @code{0}          @tab @code{-1}         @tab left
2493 @item     @code{0}          @tab @code{1}          @tab right
2494 @item     @code{1}          @tab @code{-1}         @tab below
2495 @item     @code{1}          @tab @code{1}          @tab above
2496
2497 @end multitable
2498
2499 When @code{side-axis} is @code{0}, @code{X-offset} should be set to
2500 the procedure @code{ly:side-position-interface::x-aligned-side}.
2501 This procedure will return the correct value of @code{X-offset} to
2502 place the object to the left or right side of the parent according
2503 to value of @code{direction}.
2504
2505 When @code{side-axis} is @code{1}, @code{Y-offset} should be set to
2506 the procedure @code{ly:side-position-interface::y-aligned-side}.
2507 This procedure will return the correct value of @code{Y-offset} to
2508 place the object to the top or bottom of the parent according
2509 to value of @code{direction}.
2510
2511 @c TODO Add examples
2512
2513 @node Using the @code{self-alignment-interface}
2514 @unnumberedsubsubsec Using the @code{self-alignment-interface}
2515
2516 @emph{Self-aligning objects horizontally}
2517
2518 The horizontal alignment of an object which supports the
2519 @code{self-alignment-interface} is controlled by the value of
2520 the @code{self-alignment-X} property, provided the object's
2521 @code{X-offset} property is set to
2522 @code{ly:self-alignment-interface::x-aligned-on-self}.
2523 @code{self-alignment-X}  may be given any
2524 real value, in units of half the total X extent of the
2525 object.  Negative values move the object to the right, positive
2526 to the left.  A value of @code{0} centers the object on the
2527 reference point of its parent, a value of @code{-1} aligns the
2528 left edge of the object on the reference point of its parent,
2529 and a value of @code{1} aligns the right edge of the object on the
2530 reference point of its parent.  The symbols @code{LEFT},
2531 @code{CENTER} and @code{RIGHT} may be used instead of the values
2532 @code{-1, 0, 1} respectively.
2533
2534 Normally the @code{\override} command would be used to modify the
2535 value of @code{self-alignment-X}, but the @code{\tweak} command
2536 can be used to separately align several annotations on a single
2537 note:
2538
2539 @lilypond[quote,verbatim,relative=1]
2540 a'
2541 -\tweak #'self-alignment-X #-1
2542 ^"left-aligned"
2543 -\tweak #'self-alignment-X #0
2544 ^"center-aligned"
2545 -\tweak #'self-alignment-X #RIGHT
2546 ^"right-aligned"
2547 -\tweak #'self-alignment-X #-2.5
2548 ^"aligned further to the right"
2549 @end lilypond
2550
2551 @emph{Self-aligning objects vertically}
2552
2553 Objects may be aligned vertically in an analogous way to aligning
2554 them horizontally if the @code{Y-offset} property is set to
2555 @code{ly:self-alignment-interface::y-aligned-on-self}.  However,
2556 other mechanisms are often involved in vertical alignment: the
2557 value of @code{Y-offset} is just one variable taken into account.
2558 This may make adjusting the value of some objects tricky.
2559 The units are just half the vertical extent of the object, which
2560 is usually quite small, so quite large numbers may be required.
2561 A value of @code{-1} aligns the lower edge of the object with
2562 the reference point of the parent object, a value of @code{0}
2563 aligns the center of the object with the reference point of the
2564 parent, and a value of @code{1} aligns the top edge of the object
2565 with the reference point of the parent.  The symbols @code{DOWN},
2566 @code{CENTER}, @code{UP} may be substituted for @code{-1, 0, 1}
2567 respectively.
2568
2569 @emph{Self-aligning objects in both directions}
2570
2571 By setting both @code{X-offset} and @code{Y-offset}, an object may
2572 be aligned in both directions simultaneously.
2573
2574 The following example shows how to adjust a fingering mark so
2575 that it nestles close to the note head.
2576
2577 @lilypond[quote,verbatim,relative=2]
2578 a
2579 -\tweak #'self-alignment-X #0.5  % move horizontally left
2580 -\tweak #'Y-offset #ly:self-alignment-interface::y-aligned-on-self
2581 -\tweak #'self-alignment-Y #-1  % move vertically up
2582 -3  % third finger
2583 @end lilypond
2584
2585 @ignore
2586 @unnumberedsubsubsec Using the @code{aligned-on-parent} procedures
2587
2588 @c Cannot document as they do not seem to operate consistently on all objects -td
2589 @c TODO investigate further
2590
2591 The @code{aligned-on-parent} procedures are used in the same way
2592 as the @code{aligned-on-self} procedures, they difference being
2593 that they permit an object to be aligned with the @emph{edges} of
2594 the parent rather than the parent's reference point.  The following
2595 example shows the difference:
2596
2597 @c TODO Add example
2598
2599 @lilypond[verbatim,quote]
2600 @end lilypond
2601
2602 @end ignore
2603
2604 @ignore
2605 @unnumberedsubsubsec Using the @code{centered-on-parent} procedures
2606
2607 @c Cannot document as they do not seem to operate consistently on all objects -td
2608 @c TODO investigate further
2609
2610 @end ignore
2611
2612 @c TODO The align-interface, BassFigureAlignment and VerticalAlignment
2613
2614 @node Using the @code{break-aligned-interface}
2615 @unnumberedsubsubsec Using the @code{break-aligned-interface}
2616
2617 Rehearsal marks may be aligned with notation objects other
2618 than bar lines.  These objects include @code{ambitus},
2619 @code{breathing-sign}, @code{clef}, @code{custos}, @code{staff-bar},
2620 @code{left-edge}, @code{key-cancellation}, @code{key-signature}, and
2621 @code{time-signature}.
2622
2623 By default, rehearsal marks will be horizontally centered above the
2624 object:
2625
2626 @lilypond[verbatim,quote,relative=1]
2627 e1
2628 % the RehearsalMark will be centered above the Clef
2629 \override Score.RehearsalMark #'break-align-symbols = #'(clef)
2630 \key a \major
2631 \clef treble
2632 \mark "↓"
2633 e
2634 % the RehearsalMark will be centered above the TimeSignature
2635 \override Score.RehearsalMark #'break-align-symbols = #'(time-signature)
2636 \key a \major
2637 \clef treble
2638 \time 3/4
2639 \mark "↓"
2640 e2.
2641 @end lilypond
2642
2643 The alignment of the rehearsal mark relative to the notation object
2644 can be changed, as shown in the following example.  In a score with
2645 multiple staves, this setting should be done for all the staves.
2646
2647 @lilypond[verbatim,quote,relative=1]
2648 % The RehearsalMark will be centered above the KeySignature
2649 \override Score.RehearsalMark #'break-align-symbols = #'(key-signature)
2650 \key a \major
2651 \clef treble
2652 \time 4/4
2653 \mark "↓"
2654 e1
2655 % The RehearsalMark will be aligned with the left edge of the KeySignature
2656 \once \override Score.KeySignature #'break-align-anchor-alignment = #LEFT
2657 \mark "↓"
2658 \key a \major
2659 e
2660 % The RehearsalMark will be aligned with the right edge of the KeySignature
2661 \once \override Score.KeySignature #'break-align-anchor-alignment = #RIGHT
2662 \key a \major
2663 \mark "↓"
2664 e
2665 @end lilypond
2666
2667 The rehearsal mark can also be offset to the right or left of the left edge
2668 by an arbitrary amount.  The units are staff-spaces:
2669
2670 @lilypond[verbatim,quote,relative=1]
2671 % The RehearsalMark will be aligned with the left edge of the KeySignature
2672 % and then shifted right by 3.5 staff-spaces
2673 \override Score.RehearsalMark #'break-align-symbols = #'(key-signature)
2674 \once \override Score.KeySignature #'break-align-anchor = #3.5
2675 \key a \major
2676 \mark "↓"
2677 e
2678 % The RehearsalMark will be aligned with the left edge of the KeySignature
2679 % and then shifted left by 2 staff-spaces
2680 \once \override Score.KeySignature #'break-align-anchor = #-2
2681 \key a \major
2682 \mark "↓"
2683 e
2684 @end lilypond
2685
2686 @node Advanced tweaks
2687 @section Advanced tweaks
2688
2689 @menu
2690 * Vertical grouping of grobs::
2691 * Modifying ends of spanners::
2692 * Modifying stencils::
2693 * Modifying shapes::
2694 @end menu
2695
2696
2697
2698
2699 @node Vertical grouping of grobs
2700 @subsection Vertical grouping of grobs
2701
2702 @c FIXME Expand this section
2703
2704 The VerticalAlignment and VerticalAxisGroup grobs work together.
2705 VerticalAxisGroup groups together different grobs like Staff, Lyrics,
2706 etc.  VerticalAlignment then vertically aligns the different grobs
2707 grouped together by VerticalAxisGroup.  There is usually only one
2708 VerticalAlignment per score but every Staff, Lyrics, etc. has its own
2709 VerticalAxisGroup.
2710
2711
2712 @node Modifying ends of spanners
2713 @subsection Modifying ends of spanners
2714
2715 @c FIXME Write this section
2716 @c See earlier material in Line styles
2717
2718 @node Modifying stencils
2719 @subsection Modifying stencils
2720
2721 All layout objects have a @code{stencil} property which is part of
2722 the @code{grob-interface}.  By default, this property is usually
2723 set to a function specific to the object that is tailor-made to
2724 render the symbol which represents it in the output.  For example,
2725 the standard setting for the @code{stencil} property of the
2726 @code{MultiMeasureRest} object is @code{ly:multi-measure-rest::print}.
2727
2728 The standard symbol for any object can be replaced by modifying the
2729 @code{stencil} property to reference a different, specially-written,
2730 procedure.  This requires a high level of knowledge of the internal
2731 workings of LilyPond, but there is an easier way which can often
2732 produce adequate results.
2733
2734 This is to set the @code{stencil} property to the procedure which
2735 prints text -- @code{ly:text-interface::print} -- and to add a
2736 @code{text} property to the object which is set to contain the
2737 markup text which produces the required symbol.  Due to the
2738 flexibility of markup, much can be achieved -- see in particular
2739 @ref{Graphic notation inside markup}.
2740
2741 The following example demonstrates this by changing the note head
2742 symbol to a cross within a circle.
2743
2744 @lilypond[verbatim,quote]
2745 XinO = {
2746   \once \override NoteHead  #'stencil = #ly:text-interface::print
2747   \once \override NoteHead #'text = \markup {
2748     \combine
2749       \halign #-0.7 \draw-circle #0.85 #0.2 ##f
2750       \musicglyph #"noteheads.s2cross"
2751   }
2752 }
2753 \relative c'' {
2754   a a \XinO a a
2755 }
2756 @end lilypond
2757
2758 Any of the glyphs in the feta Font can be supplied to the
2759 @code{\musicglyph} markup command -- see @ref{The Feta font}.
2760
2761 @c TODO Add inserting eps files or ref to later
2762
2763 @c TODO Add inserting Postscript or ref to later
2764
2765 @seealso
2766
2767 Notation Reference:
2768 @ref{Graphic notation inside markup},
2769 @ref{Formatting text},
2770 @ref{Text markup commands},
2771 @ref{The Feta font}.
2772
2773
2774 @node Modifying shapes
2775 @subsection Modifying shapes
2776
2777 @menu
2778 * Modifying ties and slurs::
2779 @end menu
2780
2781 @node Modifying ties and slurs
2782 @unnumberedsubsubsec Modifying ties and slurs
2783
2784 Ties, slurs and phrasing slurs are drawn as third-order Bézier
2785 curves.  If the shape of the tie or slur which is calculated
2786 automatically is not optimum, the shape may be modified manually by
2787 explicitly specifying the four control points required to define
2788 a third-order Bézier curve.
2789
2790 Third-order or cubic Bézier curves are defined by four control
2791 points.  The first and fourth control points are precisely the
2792 starting and ending points of the curve.  The intermediate two
2793 control points define the shape.  Animations showing how the curve
2794 is drawn can be found on the web, but the following description
2795 may be helpful.  The curve starts from the first control point
2796 heading directly towards the second, gradually bending over to
2797 head towards the third and continuing to bend over to head towards
2798 the fourth, arriving there travelling directly from the third
2799 control point.  The curve is entirely contained in the
2800 quadrilateral defined by the four control points.
2801
2802 Here is an example of a case where the tie is not optimum, and
2803 where @code{\tieDown} would not help.
2804
2805 @lilypond[verbatim,quote,relative=1]
2806 <<
2807   { e1 ~ e }
2808 \\
2809   { r4 <g c,> <g c,> <g c,> }
2810 >>
2811 @end lilypond
2812
2813 One way of improving this tie is to manually modify its control
2814 points, as follows.
2815
2816 The coordinates of the Bézier control points are specified in units
2817 of staff-spaces.  The X@tie{}coordinate is relative to the reference
2818 point of the note to which the tie or slur is attached, and the
2819 Y@tie{}coordinate is relative to the staff center line.  The
2820 coordinates are entered as a list of four pairs of decimal numbers
2821 (reals).  One approach is to estimate the coordinates of the two
2822 end points, and then guess the two intermediate points.  The optimum
2823 values are then found by trial and error.
2824
2825 It is useful to remember that a symmetric curve requires symmetric
2826 control points, and that Bézier curves have the useful property that
2827 transformations of the curve such as translation, rotation and
2828 scaling can be achieved by applying the same transformation to the
2829 curve's control points.
2830
2831 For the example above the following override gives a satisfactory
2832 tie:
2833
2834 @lilypond[verbatim,quote,relative=1]
2835 <<
2836   \once \override Tie
2837     #'control-points = #'((1 . -1) (3 . 0.6) (12.5 . 0.6) (14.5 . -1))
2838   { e1 ~ e1 }
2839 \\
2840   { r4 <g c,> <g c,> <g c,>4  }
2841 >>
2842 @end lilypond
2843
2844 @knownissues
2845
2846 It is not possible to modify shapes of ties or slurs by changing
2847 the @code{control-points} property if there are more than one at
2848 the same musical moment, not even by using the @code{\tweak}
2849 command.
2850
2851
2852
2853 @node Discussion of specific tweaks
2854 @section Discussion of specific tweaks
2855
2856 @menu
2857 * old Contexts explained::      
2858 @end menu
2859
2860
2861 @node old Contexts explained
2862 @subsection old Contexts explained
2863
2864 @c FIXME Delete this section?  It is in LM
2865 @c Or leave heading and go on from LM?
2866
2867 When music is printed, a lot of notational elements must be added to the
2868 output.  For example, compare the input and output of the following example:
2869
2870 @lilypond[quote,verbatim,relative=2,fragment]
2871 cis4 cis2. g4
2872 @end lilypond
2873
2874 The input is rather sparse, but in the output, bar lines, accidentals,
2875 clef, and time signature are added.  LilyPond @emph{interprets} the
2876 input.  During this step, the musical information is inspected in time
2877 order, similar to reading a score from left to right.  While reading
2878 the input, the program remembers where measure boundaries are, and which
2879 pitches require explicit accidentals.  This information can be presented on
2880 several levels.  For example, the effect of an accidental is limited
2881 to a single staff, while a bar line must be synchronized across the
2882 entire score.
2883
2884 Within LilyPond, these rules and bits of information are grouped in
2885 @emph{Contexts}.  Some examples of contexts are @code{Voice},
2886 @code{Staff}, and @code{Score}.  They are hierarchical, for
2887 example: a @code{Staff} can contain many @code{Voice}s, and a
2888 @code{Score} can contain many @code{Staff} contexts.
2889
2890 @quotation
2891 @sourceimage{context-example,5cm,,}
2892 @end quotation
2893
2894 Each context has the responsibility for enforcing some notation rules,
2895 creating some notation objects and maintaining the associated
2896 properties.  For example, the @code{Voice} context may introduce an
2897 accidental and then the @code{Staff} context maintains the rule to
2898 show or suppress the accidental for the remainder of the measure.  The
2899 synchronization of bar lines is handled at @code{Score} context.
2900
2901 However, in some music we may not want the bar lines to be
2902 synchronized -- consider a polymetric score in 4/4 and 3/4 time.  In
2903 such cases, we must modify the default settings of the @code{Score}
2904 and @code{Staff} contexts.
2905
2906 For very simple scores, contexts are created implicitly, and you need
2907 not be aware of them.  For larger pieces, such as anything with more
2908 than one staff, they must be
2909 created explicitly to make sure that you get as many staves as you
2910 need, and that they are in the correct order.  For typesetting pieces
2911 with specialized notation, it can be useful to modify existing or
2912 to define new contexts.
2913
2914
2915 A complete description of all available contexts is in the program
2916 reference, see
2917 @ifhtml
2918 @rinternals{Contexts}.
2919 @end ifhtml
2920 @ifnothtml
2921 Translation @expansion{} Context.
2922 @end ifnothtml
2923
2924 @c [TODO: describe propagation]
2925
2926
2927