]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/changing-defaults.itely
Add commented out \version to all .itely files
[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.38"
11
12 @node Changing defaults
13 @chapter Changing defaults
14
15
16 The purpose of LilyPond's design is to provide the finest output
17 quality as a default.  Nevertheless, it may happen that you need to
18 change this default layout.  The layout is controlled through a large
19 number of proverbial @q{knobs and switches.}  This chapter does not
20 list each and every knob.  Rather, it outlines what groups of controls
21 are available and explains how to lookup which knob to use for a
22 particular effect.
23
24
25 @cindex Internals Reference
26
27 The controls available for tuning are described in a separate
28 document, the
29 @iftex
30 Internals Reference manual.
31 @end iftex
32 @ifnottex
33 @ref{Top,Internals Reference,,lilypond-internals}.
34 @end ifnottex
35 That manual
36 lists all different variables, functions and options available in
37 LilyPond.  It is written as a HTML document, which is available
38 @c leave the @uref as one long line.
39 @uref{http://@/lilypond@/.org/@/doc/@/stable/@/Documentation/@/user/@/lilypond@/-internals/,on@/-line},
40 but is also included with the LilyPond documentation package.
41
42 There are four areas where the default settings may be changed:
43
44 @itemize
45 @item
46 Automatic notation: changing the automatic creation of notation
47 elements.  For example, changing the beaming rules.
48
49 @item
50 Output: changing the appearance of individual
51 objects.  For example, changing stem directions or the location of
52 subscripts.
53
54 @item
55 Context: changing aspects of the translation from music events to
56 notation.  For example, giving each staff a separate time signature.
57
58 @item
59 Page layout: changing the appearance of the spacing, line
60 breaks, and page dimensions.  These modifications are discussed
61 in @ref{Non-musical notation}, and @ref{Spacing issues}.
62 @end itemize
63
64 Internally, LilyPond uses Scheme (a LISP dialect) to provide
65 infrastructure.  Overriding layout decisions in effect accesses the
66 program internals, which requires Scheme input.  Scheme elements are
67 introduced in a @code{.ly} file with the hash mark
68 @code{#}.@footnote{@rlearning{Scheme tutorial}, contains a short tutorial
69 on entering numbers, lists, strings, and symbols in Scheme.}
70
71
72 @menu
73 * Interpretation contexts::     
74 * The \override command::       
75 * Discussion of specific tweaks::  
76 @end menu
77
78
79 @node Interpretation contexts
80 @section Interpretation contexts
81
82 This section describes what contexts are, and how to modify them.
83
84 @menu
85 * Contexts explained::          
86 * Creating contexts::           
87 * Changing context properties on the fly::  
88 * Modifying context plug-ins::  
89 * Layout tunings within contexts::  
90 * Changing context default settings::  
91 * Defining new contexts::       
92 * Aligning contexts::           
93 * Vertical grouping of grobs::  
94 @end menu
95
96
97 @node Contexts explained
98 @subsection Contexts explained
99
100 When music is printed, a lot of notational elements must be added to the
101 output.  For example, compare the input and output of the following example:
102
103 @lilypond[quote,verbatim,relative=2,fragment]
104 cis4 cis2. g4
105 @end lilypond
106
107 The input is rather sparse, but in the output, bar lines, accidentals,
108 clef, and time signature are added.  LilyPond @emph{interprets} the
109 input.  During this step, the musical information is inspected in time
110 order, similar to reading a score from left to right.  While reading
111 the input, the program remembers where measure boundaries are, and which
112 pitches require explicit accidentals.  This information can be presented on
113 several levels.  For example, the effect of an accidental is limited
114 to a single staff, while a bar line must be synchronized across the
115 entire score.
116
117 Within LilyPond, these rules and bits of information are grouped in
118 @emph{Contexts}.  Some examples of contexts are @code{Voice},
119 @code{Staff}, and @code{Score}.  They are hierarchical, for
120 example: a @code{Staff} can contain many @code{Voice}s, and a
121 @code{Score} can contain many @code{Staff} contexts.
122
123 @quotation
124 @sourceimage{context-example,5cm,,}
125 @end quotation
126
127 Each context has the responsibility for enforcing some notation rules,
128 creating some notation objects and maintaining the associated
129 properties.  For example, the @code{Voice} context may introduce an
130 accidental and then the @code{Staff} context maintains the rule to
131 show or suppress the accidental for the remainder of the measure.  The
132 synchronization of bar lines is handled at @code{Score} context.
133
134 However, in some music we may not want the bar lines to be
135 synchronized -- consider a polymetric score in 4/4 and 3/4 time.  In
136 such cases, we must modify the default settings of the @code{Score}
137 and @code{Staff} contexts.
138
139 For very simple scores, contexts are created implicitly, and you need
140 not be aware of them.  For larger pieces, such as anything with more
141 than one staff, they must be
142 created explicitly to make sure that you get as many staves as you
143 need, and that they are in the correct order.  For typesetting pieces
144 with specialized notation, it can be useful to modify existing or
145 to define new contexts.
146
147
148 A complete description of all available contexts is in the program
149 reference, see
150 @ifhtml
151 @internalsref{Contexts}.
152 @end ifhtml
153 @ifnothtml
154 Translation @expansion{} Context.
155 @end ifnothtml
156
157 @c [TODO: describe propagation]
158
159
160 @node Creating contexts
161 @subsection Creating contexts
162
163 For scores with only one voice and one staff, contexts are
164 created automatically.  For more complex scores, it is necessary to
165 create them by hand.  There are three commands that do this.
166
167 @itemize
168
169 @item
170 The easiest command is @code{\new}, and it also the quickest to type.
171 It is prepended to a music expression, for example
172
173 @funindex \new
174 @cindex new contexts
175 @cindex Context, creating
176
177 @example
178 \new @var{type} @var{music expression}
179 @end example
180
181 @noindent
182 where @var{type} is a context name (like @code{Staff} or
183 @code{Voice}).  This command creates a new context, and starts
184 interpreting the @var{music expression} with that.
185
186 A practical application of @code{\new} is a score with many
187 staves.  Each part that should be on its own staff, is preceded with
188 @code{\new Staff}.
189
190 @lilypond[quote,verbatim,relative=2,ragged-right,fragment]
191 <<
192   \new Staff { c4 c }
193   \new Staff { d4 d }
194 >>
195 @end lilypond
196
197 The @code{\new} command may also give a name to the context,
198
199 @example
200 \new @var{type} = @var{id} @var{music}
201 @end example
202 However, this user specified name is only used if there is no other
203 context already earlier with the same name.
204
205
206 @funindex \context
207
208 @item
209 Like @code{\new}, the @code{\context} command also directs a music
210 expression to a context object, but gives the context an explicit name.  The
211 syntax is
212
213 @example
214 \context @var{type} = @var{id} @var{music}
215 @end example
216
217 This form will search for an existing context of type @var{type}
218 called @var{id}.  If that context does not exist yet, a new
219 context with the specified name is created.  This is useful if
220 the context is referred to later on.  For example, when
221 setting lyrics the melody is in a named context
222
223 @example
224 \context Voice = "@b{tenor}" @var{music}
225 @end example
226
227 @noindent
228 so the texts can be properly aligned to its notes,
229
230 @example
231 \new Lyrics \lyricsto "@b{tenor}" @var{lyrics}
232 @end example
233
234 @noindent
235
236 Another possible use of named contexts is funneling two different
237 music expressions into one context.  In the following example,
238 articulations and notes are entered separately,
239
240 @example
241 music = @{ c4 c4 @}
242 arts = @{ s4-. s4-> @}
243 @end example
244
245 They are combined by sending both to the same @code{Voice} context,
246
247 @example
248 <<
249   \new Staff \context Voice = "A" \music
250   \context Voice = "A" \arts
251 >>
252 @end example
253 @lilypond[quote,ragged-right]
254 music = { c4 c4 }
255 arts = { s4-. s4-> }
256 \relative c'' <<
257   \new Staff \context Voice = "A" \music
258   \context Voice = "A" \arts
259 >>
260 @end lilypond
261
262 With this mechanism, it is possible to define an Urtext (original
263 edition), with the option to put several distinct articulations on the
264 same notes.
265
266 @cindex creating contexts
267
268 @item
269 The third command for creating contexts is
270 @example
271 \context @var{type} @var{music}
272 @end example
273
274
275 @noindent
276 This is similar to @code{\context} with @code{= @var{id}}, but matches
277 any context of type @var{type}, regardless of its given name.
278
279 This variant is used with music expressions that can be interpreted at
280 several levels.  For example, the @code{\applyOutput} command (see
281 @ref{Running a function on all layout objects}).  Without an explicit
282 @code{\context}, it is usually applied to @code{Voice}
283
284 @example
285 \applyOutput #'@var{context} #@var{function}   % apply to Voice
286 @end example
287
288 To have it interpreted at the @code{Score} or @code{Staff} level use
289 these forms
290
291 @example
292 \applyOutput #'Score #@var{function}
293 \applyOutput #'Staff #@var{function}
294 @end example
295
296 @end itemize
297
298
299 @node Changing context properties on the fly
300 @subsection Changing context properties on the fly
301
302 @cindex properties
303 @funindex \set
304 @cindex changing properties
305
306 Each context can have different @emph{properties}, variables contained
307 in that context.  They can be changed during the interpretation step.
308 This is achieved by inserting the @code{\set} command in the music,
309
310 @example
311 \set @var{context}.@var{prop} = #@var{value}
312 @end example
313
314 For example,
315 @lilypond[quote,verbatim,relative=2,fragment]
316 R1*2
317 \set Score.skipBars = ##t
318 R1*2
319 @end lilypond
320
321 This command skips measures that have no notes.  The result is that
322 multi-rests are condensed.  The value assigned is a Scheme object.  In
323 this case, it is @code{#t}, the boolean True value.
324
325 If the @var{context} argument is left out, then the current bottom-most
326 context (typically @code{ChordNames}, @code{Voice}, or
327 @code{Lyrics}) is used.  In this example,
328
329 @lilypond[quote,verbatim,relative=2,fragment]
330 c8 c c c
331 \set autoBeaming = ##f
332 c8 c c c
333 @end lilypond
334
335 @noindent
336 the @var{context} argument to @code{\set} is left out, so automatic
337 beaming is switched off in the current @internalsref{Voice}.  Note that
338 the bottom-most context does not always contain the property that you
339 wish to change -- for example, attempting to set the @code{skipBars}
340 property (of the bottom-most context, in this case @code{Voice}) will
341 have no effect.
342
343 @lilypond[quote,verbatim,relative=2,fragment]
344 R1*2
345 \set skipBars = ##t
346 R1*2
347 @end lilypond
348
349 Contexts are hierarchical, so if a bigger context was specified, for
350 example @code{Staff}, then the change would also apply to all
351 @code{Voice}s in the current stave.  The change is applied
352 @q{on-the-fly}, during the music, so that the setting only affects the
353 second group of eighth notes.
354
355 @funindex \unset
356
357 There is also an @code{\unset} command,
358 @example
359 \unset @var{context}.@var{prop}
360 @end example
361
362 @noindent
363 which removes the definition of @var{prop}.  This command removes
364 the definition only if it is set in @var{context}, so
365
366 @example
367 \set Staff.autoBeaming = ##f
368 @end example
369
370 @noindent
371 introduces a property setting at @code{Staff} level.  The setting also
372 applies to the current @code{Voice}.  However,
373
374 @example
375 \unset Voice.autoBeaming
376 @end example
377
378 @noindent
379 does not have any effect.  To cancel this setting, the @code{\unset}
380 must be specified on the same level as the original @code{\set}.  In
381 other words, undoing the effect of @code{Staff.autoBeaming = ##f}
382 requires
383 @example
384 \unset Staff.autoBeaming
385 @end example
386
387 Like @code{\set}, the @var{context} argument does not have to be
388 specified for a bottom context, so the two statements
389
390 @example
391 \set Voice.autoBeaming = ##t
392 \set autoBeaming = ##t
393 @end example
394
395 @noindent
396 are equivalent.
397
398
399 @cindex \once
400 Settings that should only apply to a single time-step can be entered
401 with @code{\once}, for example in
402
403 @lilypond[quote,verbatim,relative=2,fragment]
404 c4
405 \once \set fontSize = #4.7
406 c4
407 c4
408 @end lilypond
409
410 the property @code{fontSize} is unset automatically after the second
411 note.
412
413 A full description of all available context properties is in the
414 program reference, see
415 @ifhtml
416 @internalsref{Tunable context properties}.
417 @end ifhtml
418 @ifnothtml
419 Translation @expansion{} Tunable context properties.
420 @end ifnothtml
421
422
423 @node Modifying context plug-ins
424 @subsection Modifying context plug-ins
425
426 Notation contexts (like @code{Score} and @code{Staff}) not only
427 store properties,
428 they also contain plug-ins called @q{engravers} that create notation
429 elements.  For example, the @code{Voice} context contains a
430 @code{Note_head_engraver} and the @code{Staff} context contains a
431 @code{Key_signature_engraver}.
432
433 For a full a description of each plug-in, see
434 @ifhtml
435 @internalsref{Engravers and Performers}.
436 @end ifhtml
437 @ifnothtml
438 Internals Reference @expansion{} Translation @expansion{} Engravers.
439 @end ifnothtml
440 Every context described in
441 @ifhtml
442 @internalsref{Contexts}
443 @end ifhtml
444 @ifnothtml
445 Internals Reference @expansion{} Translation @expansion{} Context.
446 @end ifnothtml
447 lists the engravers used for that context.
448
449
450 It can be useful to shuffle around these plug-ins.  This is done by
451 starting a new context with @code{\new} or @code{\context}, and
452 modifying it,
453
454 @funindex \with
455
456 @example
457 \new @var{context} \with @{
458   \consists @dots{}
459   \consists @dots{}
460   \remove @dots{}
461   \remove @dots{}
462   @emph{etc.}
463 @}
464 @{
465   @emph{..music..}
466 @}
467 @end example
468
469 @noindent
470 where the @dots{} should be the name of an engraver.  Here is a simple
471 example which removes @code{Time_signature_engraver} and
472 @code{Clef_engraver} from a @code{Staff} context,
473
474 @lilypond[quote,relative=1,verbatim,fragment]
475 <<
476   \new Staff {
477     f2 g
478   }
479   \new Staff \with {
480      \remove "Time_signature_engraver"
481      \remove "Clef_engraver"
482   } {
483     f2 g2
484   }
485 >>
486 @end lilypond
487
488 In the second staff there are no time signature or clef symbols.  This
489 is a rather crude method of making objects disappear since it will affect
490 the entire staff.  This method also influences the spacing, which may or
491 may not be desirable.  A more
492 sophisticated method of blanking objects is shown in @rlearning{Common tweaks}.
493
494 The next example shows a practical application.  Bar lines and time
495 signatures are normally synchronized across the score.  This is done
496 by the @code{Timing_translator} and @code{Default_bar_line_engraver}.
497 This plug-in keeps an administration of time signature, location
498 within the measure, etc.  By moving these engraver from @code{Score} to
499 @code{Staff} context, we can have a score where each staff has its own
500 time signature.
501
502 @cindex polymetric scores
503 @cindex Time signatures, multiple
504
505 @lilypond[quote,relative=1,ragged-right,verbatim,fragment]
506 \new Score \with {
507   \remove "Timing_translator"
508   \remove "Default_bar_line_engraver"
509 } <<
510   \new Staff \with {
511     \consists "Timing_translator"
512     \consists "Default_bar_line_engraver"
513   } {
514       \time 3/4
515       c4 c c c c c
516   }
517   \new Staff \with {
518     \consists "Timing_translator"
519     \consists "Default_bar_line_engraver"
520   } {
521        \time 2/4
522        c4 c c c c c
523   }
524 >>
525 @end lilypond
526
527
528 @node Layout tunings within contexts
529 @subsection Layout tunings within contexts
530
531 Each context is responsible for creating certain types of graphical
532 objects.  The settings used for printing these objects are also stored by
533 context.  By changing these settings, the appearance of objects can be
534 altered.
535
536 The syntax for this is
537
538 @example
539 \override @var{context}.@var{name} #'@var{property} = #@var{value}
540 @end example
541
542 Here @var{name} is the name of a graphical object, like @code{Stem} or
543 @code{NoteHead}, and @var{property} is an internal variable of the
544 formatting system (@q{grob property} or @q{layout property}).  The latter is a
545 symbol, so it must be quoted.  The subsection @ref{Constructing a
546 tweak}, explains what to fill in for @var{name}, @var{property}, and
547 @var{value}.  Here we only discuss the functionality of this command.
548
549 The command
550
551 @verbatim
552 \override Staff.Stem #'thickness = #4.0
553 @end verbatim
554
555 @noindent
556 makes stems thicker (the default is 1.3, with staff line thickness as a
557 unit).  Since the command specifies @code{Staff} as context, it only
558 applies to the current staff.  Other staves will keep their normal
559 appearance.  Here we see the command in action:
560
561 @lilypond[quote,verbatim,relative=2,fragment]
562 c4
563 \override Staff.Stem #'thickness = #4.0
564 c4
565 c4
566 c4
567 @end lilypond
568
569 The @code{\override} command changes the definition of the @code{Stem}
570 within the current @code{Staff}.  After the command is interpreted
571 all stems are thickened.
572
573 Analogous to @code{\set}, the @var{context} argument may be left out,
574 causing the default context @code{Voice} to be used.  Adding
575 @code{\once} applies the change during one timestep only.
576
577 @lilypond[quote,fragment,verbatim,relative=2]
578 c4
579 \once \override Stem #'thickness = #4.0
580 c4
581 c4
582 @end lilypond
583
584 The @code{\override} must be done before the object is
585 started.  Therefore, when altering @emph{Spanner} objects such as slurs
586 or beams, the @code{\override} command must be executed at the moment
587 when the object is created.  In this example,
588
589 @lilypond[quote,fragment,verbatim,relative=2]
590 \override Slur #'thickness = #3.0
591 c8[( c
592 \override Beam #'thickness = #0.6
593 c8 c])
594 @end lilypond
595
596 @noindent
597 the slur is fatter but the beam is not.  This is because the command for
598 @code{Beam} comes after the Beam is started, so it has no effect.
599
600 Analogous to @code{\unset}, the @code{\revert} command for a context
601 undoes an @code{\override} command; like with @code{\unset}, it only
602 affects settings that were made in the same context.  In other words, the
603 @code{\revert} in the next example does not do anything.
604
605 @example
606 \override Voice.Stem #'thickness = #4.0
607 \revert Staff.Stem #'thickness
608 @end example
609
610 Some tweakable options are called @q{subproperties} and reside inside
611 properties.  To tweak those, use commands of the form
612
613 @c leave this as a long long
614 @example
615 \override @var{context}.@var{name} #'@var{property} #'@var{subproperty} = #@var{value}
616 @end example
617
618 @noindent
619 such as
620
621 @example
622 \override Stem #'details #'beamed-lengths = #'(4 4 3)
623 @end example
624
625
626 @seealso
627
628 Internals: @internalsref{OverrideProperty}, @internalsref{RevertProperty},
629 @internalsref{PropertySet}, @internalsref{Backend}, and
630 @internalsref{All layout objects}.
631
632
633 @knownissues
634
635 The back-end is not very strict in type-checking object properties.
636 Cyclic references in Scheme values for properties can cause hangs
637 or crashes, or both.
638
639
640 @node Changing context default settings
641 @subsection Changing context default settings
642
643 The adjustments of the previous subsections (@ref{Changing context
644 properties on the fly}, @ref{Modifying context plug-ins}, and
645 @ref{Layout tunings within contexts}) can also be entered separately
646 from the music in the @code{\layout} block,
647
648 @example
649 \layout @{
650   @dots{}
651   \context @{
652     \Staff
653
654     \set fontSize = #-2
655     \override Stem #'thickness = #4.0
656     \remove "Time_signature_engraver"
657   @}
658 @}
659 @end example
660
661 The @code{\Staff} command brings in the existing definition of the
662 staff context so that it can be modified.
663
664 The statements
665 @example
666 \set fontSize = #-2
667 \override Stem #'thickness = #4.0
668 \remove "Time_signature_engraver"
669 @end example
670
671 @noindent
672 affect all staves in the score.  Other contexts can be modified
673 analogously.
674
675 The @code{\set} keyword is optional within the @code{\layout} block, so
676
677 @example
678 \context @{
679   @dots{}
680   fontSize = #-2
681 @}
682 @end example
683
684 @noindent
685 will also work.
686
687
688
689 @knownissues
690
691 It is not possible to collect context changes in a variable and apply
692 them to a @code{\context} definition by referring to that variable.
693
694 The @code{\RemoveEmptyStaffContext} will overwrite your current
695 @code{\Staff} settings.  If you wish to change the defaults for a
696 staff which uses @code{\RemoveEmptyStaffContext}, you must do so
697 after calling @code{\RemoveEmptyStaffContext}, ie
698
699 @example
700 \layout @{
701   \context @{
702     \RemoveEmptyStaffContext
703
704     \override Stem #'thickness = #4.0
705   @}
706 @}
707 @end example
708
709
710 @node Defining new contexts
711 @subsection Defining new contexts
712
713 Specific contexts, like @code{Staff} and @code{Voice}, are made of
714 simple building blocks.  It is possible to create new types of
715 contexts with different combinations of engraver plug-ins.
716
717 The next example shows how to build a different type of
718 @code{Voice} context from scratch.  It will be similar to
719 @code{Voice}, but only prints centered slash note heads.  It can be used
720 to indicate improvisation in jazz pieces,
721
722 @lilypond[quote,ragged-right]
723 \layout { \context {
724   \name ImproVoice
725   \type "Engraver_group"
726   \consists "Note_heads_engraver"
727   \consists "Text_engraver"
728   \consists Pitch_squash_engraver
729   squashedPosition = #0
730   \override NoteHead #'style = #'slash
731   \override Stem #'transparent = ##t
732   \alias Voice
733 }
734 \context { \Staff
735   \accepts "ImproVoice"
736 }}
737
738 \relative c'' {
739   a4 d8 bes8 \new ImproVoice { c4^"ad lib" c
740    c4 c^"undress" c_"while playing :)" c }
741   a1
742 }
743 @end lilypond
744
745
746 These settings are defined within a @code{\context} block inside a
747 @code{\layout} block,
748
749 @example
750 \layout @{
751   \context @{
752     @dots{}
753   @}
754 @}
755 @end example
756
757 In the following discussion, the example input shown should go in place
758 of the @dots{} in the previous fragment.
759
760 First it is necessary to define a name for the new context:
761
762 @example
763 \name ImproVoice
764 @end example
765
766 Since it is similar to the @code{Voice}, we want commands that work
767 on (existing) @code{Voice}s to remain working.  This is achieved by
768 giving the new context an alias @code{Voice},
769
770 @example
771 \alias Voice
772 @end example
773
774 The context will print notes and instructive texts, so we need to add
775 the engravers which provide this functionality,
776
777 @example
778 \consists Note_heads_engraver
779 \consists Text_engraver
780 @end example
781
782 but we only need this on the center line,
783
784 @example
785 \consists Pitch_squash_engraver
786 squashedPosition = #0
787 @end example
788
789 The @internalsref{Pitch_squash_engraver} modifies note heads (created
790 by @internalsref{Note_heads_engraver}) and sets their vertical
791 position to the value of @code{squashedPosition}, in this case@tie{}@code{0},
792 the center line.
793
794 The notes look like a slash, and have no stem,
795
796 @example
797 \override NoteHead #'style = #'slash
798 \override Stem #'transparent = ##t
799 @end example
800
801 All these plug-ins have to cooperate, and this is achieved with a
802 special plug-in, which must be marked with the keyword @code{\type}.
803 This should always be @internalsref{Engraver_group},
804
805 @example
806 \type "Engraver_group"
807 @end example
808
809 Put together, we get
810
811 @example
812 \context @{
813   \name ImproVoice
814   \type "Engraver_group"
815   \consists "Note_heads_engraver"
816   \consists "Text_engraver"
817   \consists Pitch_squash_engraver
818   squashedPosition = #0
819   \override NoteHead #'style = #'slash
820   \override Stem #'transparent = ##t
821   \alias Voice
822 @}
823 @end example
824
825 @funindex \accepts
826 Contexts form hierarchies.  We want to hang the @code{ImproVoice}
827 under @code{Staff}, just like normal @code{Voice}s.  Therefore, we
828 modify the @code{Staff} definition with the @code{\accepts}
829 command,
830
831 @example
832 \context @{
833   \Staff
834   \accepts ImproVoice
835 @}
836 @end example
837
838 @funindex \denies
839 The opposite of @code{\accepts} is @code{\denies},
840 which is sometimes needed when reusing existing context definitions.
841
842 Putting both into a @code{\layout} block, like
843
844 @example
845 \layout @{
846   \context @{
847     \name ImproVoice
848     @dots{}
849   @}
850   \context @{
851     \Staff
852     \accepts "ImproVoice"
853   @}
854 @}
855 @end example
856
857 Then the output at the start of this subsection can be entered as
858
859 @example
860 \relative c'' @{
861   a4 d8 bes8
862   \new ImproVoice @{
863     c4^"ad lib" c
864     c4 c^"undress"
865     c c_"while playing :)"
866   @}
867   a1
868 @}
869 @end example
870
871
872 @node Aligning contexts
873 @subsection Aligning contexts
874
875 New contexts may be aligned above or below existing contexts.  This
876 could be useful in setting up a vocal staff (@rlearning{Vocal ensembles}) and
877 in ossia,
878
879 FIXME: this section doesn't work in pdf.  (?)
880
881 @cindex ossia
882 @findex alignAboveContext
883 @findex alignBelowContext
884
885 @lilypond[quote,ragged-right]
886 ossia = { f4 f f f }
887 \score{
888   \relative c' \new Staff = "main" {
889     c4 c c c
890     <<
891       \new Staff \with {alignAboveContext=main} \ossia
892       { d8 f d f d f d f }
893     >>
894   }
895 }
896 @end lilypond
897
898
899 @node Vertical grouping of grobs
900 @subsection Vertical grouping of grobs
901
902 The VerticalAlignment and VerticalAxisGroup grobs work together.
903 VerticalAxisGroup groups together different grobs like Staff, Lyrics,
904 etc.  VerticalAlignment then vertically aligns the different grobs
905 grouped together by VerticalAxisGroup.  There is usually only one
906 VerticalAlignment per score but every Staff, Lyrics, etc. has its own
907 VerticalAxisGroup. 
908
909
910 @node The \override command
911 @section The @code{\override} command
912
913 In the previous section, we have already touched on a command that
914 changes layout details: the @code{\override} command.  In this section,
915 we will look in more detail at how to use the command in practice.  The
916 general syntax of this command is:
917
918 @example
919 \override @var{context}.@var{layout_object} #'@var{layout_property} = #@var{value}
920 @end example
921
922 This will set the @var{layout_property} of the specified @var{layout_object},
923 which is a member of the @var{context}, to the @var{value}.
924
925 @menu
926 * Constructing a tweak::        
927 * Navigating the program reference::  
928 * Layout interfaces::           
929 * Determining the grob property::  
930 * Objects connected to the input::  
931 * Using Scheme code instead of \tweak::  
932 * \set versus \override::       
933 * Difficult tweaks::            
934 @end menu
935
936
937
938 @node Constructing a tweak
939 @subsection Constructing a tweak
940
941 Commands which change output generally look like
942
943 @example
944 \override Voice.Stem #'thickness = #3.0
945 @end example
946
947 @noindent
948 To construct this tweak we must determine these bits of information:
949
950 @itemize
951 @item the context: here @code{Voice}.
952 @item the layout object: here @code{Stem}.
953 @item the layout property: here @code{thickness}.
954 @item a sensible value: here @code{3.0}.
955 @end itemize
956
957 Some tweakable options are called @q{subproperties} and reside inside
958 properties.  To tweak those, use commands in the form
959
960 @example
961 \override Stem #'details #'beamed-lengths = #'(4 4 3)
962 @end example
963
964 @cindex internal documentation
965 @cindex finding graphical objects
966 @cindex graphical object descriptions
967 @cindex tweaking
968 @funindex \override
969 @cindex internal documentation
970
971 For many properties, regardless of the data type of the property, setting the
972 property to false ( @code{##f} ) will result in turning it off, causing
973 LilyPond to ignore that property entirely.  This is particularly useful for
974 turning off grob properties which may otherwise be causing problems.
975
976 We demonstrate how to glean this information from the notation manual
977 and the program reference.
978
979
980
981
982 @node Navigating the program reference
983 @subsection Navigating the program reference
984
985 Suppose we want to move the fingering indication in the fragment
986 below:
987
988 @lilypond[quote,fragment,relative=2,verbatim]
989 c-2
990 \stemUp
991 f
992 @end lilypond
993
994 If you visit the documentation on fingering instructions (in
995 @ref{Fingering instructions}), you will notice:
996
997 @quotation
998 @seealso
999
1000 Internals Reference: @internalsref{Fingering}.
1001
1002 @end quotation
1003
1004
1005 @c  outdated info; probably will delete.
1006 @ignore
1007 This fragment points to two parts of the program reference: a page
1008 on @code{FingerEvent} and one on @code{Fingering}.
1009
1010 The page on @code{FingerEvent} describes the properties of the music
1011 expression for the input @code{-2}.  The page contains many links
1012 forward.  For example, it says
1013
1014 @quotation
1015 Accepted by: @internalsref{Fingering_engraver},
1016 @end quotation
1017
1018 @noindent
1019 That link brings us to the documentation for the Engraver, the
1020 plug-in, which says
1021
1022 @quotation
1023 This engraver creates the following layout objects: @internalsref{Fingering}.
1024 @end quotation
1025
1026 In other words, once the @code{FingerEvent}s are interpreted, the
1027 @code{Fingering_engraver} plug-in will process them.
1028 @end ignore
1029
1030 @ignore
1031 @c  I can't figure out what this is supposed to mean.  -gp
1032
1033 The @code{Fingering_engraver} is also listed to create
1034 @internalsref{Fingering} objects,
1035
1036 @c  old info?  it doesn't make any sense to me with our current docs.
1037 This is also the
1038 second bit of information listed under @b{See also} in the Notation
1039 manual.
1040 @end ignore
1041
1042 @ifnothtml
1043 The programmer's reference is available as an HTML document.  It is
1044 highly recommended that you read it in HTML form, either online or
1045 by downloading the HTML documentation.  This section will be much more
1046 difficult to understand if you are using the 
1047 PDF manual.
1048 @end ifnothtml
1049
1050 Follow the link to @internalsref{Fingering}.  At the top of the
1051 page, you will see
1052
1053 @quotation
1054 Fingering objects are created by: @internalsref{Fingering_engraver} and
1055 @internalsref{New_fingering_engraver}.
1056 @end quotation
1057
1058 By following related links inside the program reference, we can follow the
1059 flow of information within the program:
1060
1061 @itemize
1062
1063 @item @internalsref{Fingering}:
1064 @internalsref{Fingering} objects are created by:
1065 @internalsref{Fingering_engraver}
1066
1067 @item @internalsref{Fingering_engraver}:
1068 Music types accepted: @internalsref{fingering-event}
1069
1070 @item @internalsref{fingering-event}:
1071 Music event type @code{fingering-event} is in Music expressions named
1072 @internalsref{FingerEvent}
1073 @end itemize
1074
1075 This path goes against the flow of information in the program: it
1076 starts from the output, and ends at the input event.  You could
1077 also start at an input event, and read with the flow of
1078 information, eventually ending up at the output object(s).
1079
1080 The program reference can also be browsed like a normal document.  It
1081 contains chapters on
1082 @ifhtml
1083 @internalsref{Music definitions},
1084 @end ifhtml
1085 @ifnothtml
1086 @code{Music definitions}
1087 @end ifnothtml
1088 on @internalsref{Translation}, and the @internalsref{Backend}.  Every
1089 chapter lists all the definitions used and all properties that may be
1090 tuned.
1091
1092
1093 @node Layout interfaces
1094 @subsection Layout interfaces
1095
1096 @cindex interface, layout
1097 @cindex layout interface
1098 @cindex grob
1099
1100 The HTML page that we found in the previous section describes the
1101 layout object called @internalsref{Fingering}.  Such an object is a
1102 symbol within the score.  It has properties that store numbers (like
1103 thicknesses and directions), but also pointers to related objects.  A
1104 layout object is also called a @emph{Grob}, which is short for Graphical
1105 Object.  For more details about Grobs, see @internalsref{grob-interface}.
1106
1107 The page for @code{Fingering} lists the definitions for the
1108 @code{Fingering} object.  For example, the page says
1109
1110 @quotation
1111 @code{padding} (dimension, in staff space):
1112
1113 @code{0.5}
1114 @end quotation
1115
1116 @noindent
1117 which means that the number will be kept at a distance of at least 0.5
1118 of the note head.
1119
1120
1121 Each layout object may have several functions as a notational or
1122 typographical element.  For example, the Fingering object
1123 has the following aspects
1124
1125 @itemize
1126 @item
1127 Its size is independent of the horizontal spacing, unlike slurs or beams.
1128
1129 @item
1130 It is a piece of text.  Granted, it is usually a very short text.
1131
1132 @item
1133 That piece of text is typeset with a font, unlike slurs or beams.
1134
1135 @item
1136 Horizontally, the center of the symbol should be aligned to the
1137 center of the note head.
1138
1139 @item
1140 Vertically, the symbol is placed next to the note and the staff.
1141
1142 @item
1143 The vertical position is also coordinated with other superscript
1144 and subscript symbols.
1145 @end itemize
1146
1147 Each of these aspects is captured in so-called @emph{interface}s,
1148 which are listed on the @internalsref{Fingering} page at the bottom
1149
1150 @quotation
1151 This object supports the following interfaces:
1152 @internalsref{item-interface},
1153 @internalsref{self-alignment-interface},
1154 @internalsref{side-position-interface}, @internalsref{text-interface},
1155 @internalsref{text-script-interface}, @internalsref{font-interface},
1156 @internalsref{finger-interface}, and @internalsref{grob-interface}.
1157 @end quotation
1158
1159 Clicking any of the links will take you to the page of the respective
1160 object interface.  Each interface has a number of properties.  Some of
1161 them are not user-serviceable (@q{Internal properties}), but others
1162 can be modified.
1163
1164 We have been talking of @emph{the} @code{Fingering} object, but actually it
1165 does not amount to much.  The initialization file (see
1166 @rlearning{Default files})
1167 @file{scm/@/define@/-grobs@/.scm} shows the soul of the @q{object},
1168
1169 @example
1170 (Fingering
1171   . ((padding . 0.5)
1172      (avoid-slur . around)
1173      (slur-padding . 0.2)
1174      (staff-padding . 0.5)
1175      (self-alignment-X . 0)
1176      (self-alignment-Y . 0)
1177      (script-priority . 100)
1178      (stencil . ,ly:text-interface::print)
1179      (direction . ,ly:script-interface::calc-direction)
1180      (font-encoding . fetaNumber)
1181      (font-size . -5)           ; don't overlap when next to heads.
1182      (meta . ((class . Item)
1183      (interfaces . (finger-interface
1184                     font-interface
1185                     text-script-interface
1186                     text-interface
1187                     side-position-interface
1188                     self-alignment-interface
1189                     item-interface))))))
1190 @end example
1191
1192 @noindent
1193 As you can see, the @code{Fingering} object is nothing more than a
1194 bunch of variable settings, and the webpage in the Internals Reference
1195 is directly generated from this definition.
1196
1197
1198 @node Determining the grob property
1199 @subsection Determining the grob property
1200
1201 Recall that we wanted to change the position of the @b{2} in
1202
1203 @lilypond[quote,fragment,relative=2,verbatim]
1204 c-2
1205 \stemUp
1206 f
1207 @end lilypond
1208
1209 Since the @b{2} is vertically positioned next to its note, we have to
1210 meddle with the interface associated with this positioning.  This is
1211 done using @code{side-position-interface}.  The page for this interface
1212 says
1213
1214 @quotation
1215 @code{side-position-interface}
1216
1217 Position a victim object (this one) next to other objects (the
1218 support).  The property @code{direction} signifies where to put the
1219 victim object relative to the support (left or right, up or down?)
1220 @end quotation
1221
1222 @cindex padding
1223 @noindent
1224 Below this description, the variable @code{padding} is described as
1225
1226 @quotation
1227 @table @code
1228 @item padding
1229 (dimension, in staff space)
1230
1231 Add this much extra space between objects that are next to each other.
1232 @end table
1233 @end quotation
1234
1235 By increasing the value of @code{padding}, we can move the
1236 fingering away from the note head.  The following command inserts
1237 3 staff spaces of white
1238 between the note and the fingering:
1239 @example
1240 \once \override Voice.Fingering #'padding = #3
1241 @end example
1242
1243 Inserting this command before the Fingering object is created,
1244 i.e., before @code{c2}, yields the following result:
1245
1246 @lilypond[quote,relative=2,fragment,verbatim]
1247 \once \override Voice.Fingering #'padding = #3
1248 c-2
1249 \stemUp
1250 f
1251 @end lilypond
1252
1253
1254 In this case, the context for this tweak is @code{Voice}.  This
1255 fact can also be deduced from the program reference, for the page for
1256 the @internalsref{Fingering_engraver} plug-in says
1257
1258 @quotation
1259 Fingering_engraver is part of contexts: @dots{} @internalsref{Voice}
1260 @end quotation
1261
1262
1263 @node Objects connected to the input
1264 @subsection Objects connected to the input
1265
1266 @funindex \tweak
1267
1268 In some cases, it is possible to take a short-cut for tuning graphical
1269 objects.  For objects that result directly from a piece of the input,
1270 you can use the @code{\tweak} function, for example
1271
1272 @lilypond[relative=2,fragment,verbatim,ragged-right]
1273 <
1274   c
1275   \tweak #'color #red d
1276   g
1277   \tweak #'duration-log #1  a
1278 >4-\tweak #'padding #10 -.
1279 @end lilypond
1280
1281 As you can see, properties are set in the objects directly,
1282 without mentioning the grob name or context where this should be
1283 applied.
1284
1285 This technique only works for objects that are directly connected to
1286 an @internalsref{Event} from the input, for example
1287
1288 @itemize
1289 @item note heads, caused by chord-pitch (i.e., notes inside a chord)
1290 @item articulation signs, caused by articulation instructions
1291 @end itemize
1292
1293 It notably does not work for stems and accidentals (these are caused
1294 by note heads, not by music events) or clefs (these are not caused by
1295 music inputs, but rather by the change of a property value).
1296
1297 There are very few objects which are @emph{directly} connected to
1298 output.  A normal note (like @code{c4}) is not directly connected
1299 to output, so
1300
1301 @example
1302 \tweak #'color #red c4
1303 @end example
1304
1305 @noindent
1306 does not change color.  See @ref{Displaying music expressions}, for
1307 details.
1308
1309
1310 @node Using Scheme code instead of \tweak
1311 @subsection Using Scheme code instead of @code{\tweak}
1312
1313 The main disadvantage of @code{\tweak} is its syntactical
1314 inflexibility.  For example, the following produces a syntax error.
1315
1316 @example
1317 F = \tweak #'font-size #-3 -\flageolet
1318
1319 \relative c'' @{
1320   c4^\F c4_\F
1321 @}
1322 @end example
1323
1324 @noindent
1325 With other words, @code{\tweak} doesn't behave like an articulation
1326 regarding the syntax; in particular, it can't be attached with
1327 @code{^} and @code{_}.
1328
1329 Using Scheme, this problem can be circumvented.  The route to the
1330 result is given in @ref{Adding articulation to notes (example)},
1331 especially how to use @code{\displayMusic} as a helping guide.
1332
1333 @example
1334 F = #(let ((m (make-music 'ArticulationEvent
1335                           'articulation-type "flageolet")))
1336        (set! (ly:music-property m 'tweaks)
1337              (acons 'font-size -3
1338                     (ly:music-property m 'tweaks)))
1339        m)
1340  
1341 \relative c'' @{
1342   c4^\F c4_\F
1343 @}
1344 @end example
1345
1346 @noindent
1347 Here, the @code{tweaks} properties of the flageolet object
1348 @code{m} (created with @code{make-music}) are extracted with
1349 @code{ly:music-property}, a new key-value pair to change the
1350 font size is prepended to the property list with the
1351 @code{acons} Scheme function, and the result is finally
1352 written back with @code{set!}.  The last element of the
1353 @code{let} block is the return value, @code{m} itself.
1354
1355
1356 @node \set versus \override
1357 @subsection @code{\set} vs. @code{\override}
1358
1359 We have seen two methods of changing properties: @code{\set} and
1360 @code{\override}.  There are actually two different kinds of
1361 properties.
1362
1363 Contexts can have properties, which are usually named in
1364 @code{studlyCaps}.  They mostly control the translation from
1365 music to notation, eg. @code{localKeySignature} (for determining
1366 whether to print accidentals), @code{measurePosition} (for
1367 determining when to print a bar line).  Context properties can
1368 change value over time while interpreting a piece of music;
1369 @code{measurePosition} is an obvious example of
1370 this.  Context properties are modified with @code{\set}.
1371
1372 There is a special type of context property: the element
1373 description.  These properties are named in @code{StudlyCaps}
1374 (starting with capital letters).  They contain the
1375 @q{default settings} for said graphical object as an
1376 association list.  See @file{scm/@/define@/-grobs@/.scm}
1377 to see what kind of settings there are.  Element descriptions
1378 may be modified with @code{\override}.
1379
1380 @code{\override} is actually a shorthand;
1381
1382 @example
1383 \override @var{context}.@var{name} #'@var{property} = #@var{value}
1384 @end example
1385
1386 @noindent
1387 is more or less equivalent to
1388
1389 @c  leave this long line -gp
1390 @example
1391 \set @var{context}.@var{name} #'@var{property} = #(cons (cons '@var{property} @var{value}) <previous value of @var{context})
1392 @end example
1393
1394 The value of @code{context} (the alist) is used to initialize
1395 the properties of individual grobs.  Grobs also have
1396 properties, named in Scheme style, with
1397 @code{dashed-words}.  The values of grob properties change
1398 during the formatting process: formatting basically amounts
1399 to computing properties using callback functions.
1400
1401 @code{fontSize} is a special property: it is equivalent to
1402 entering @code{\override ... #'font-size} for all pertinent
1403 objects.  Since this is a common change, the special
1404 property (modified with @code{\set}) was created.
1405
1406
1407 @node Difficult tweaks
1408 @subsection Difficult tweaks
1409
1410 There are a few classes of difficult adjustments.
1411
1412 @itemize
1413
1414
1415 @item
1416 One type of difficult adjustment is the appearance of spanner objects,
1417 such as slur and tie.  Initially, only one of these objects is created,
1418 and they can be adjusted with the normal mechanism.  However, in some
1419 cases the spanners cross line breaks.  If this happens, these objects
1420 are cloned.  A separate object is created for every system that it is
1421 in.  These are clones of the original object and inherit all
1422 properties, including @code{\override}s.
1423
1424
1425 In other words, an @code{\override} always affects all pieces of a
1426 broken spanner.  To change only one part of a spanner at a line break,
1427 it is necessary to hook into the formatting process.  The
1428 @code{after-line-breaking} callback contains the Scheme procedure that
1429 is called after the line breaks have been determined, and layout
1430 objects have been split over different systems.
1431
1432 In the following example, we define a procedure
1433 @code{my-callback}.  This procedure
1434
1435 @itemize
1436 @item
1437 determines if we have been split across line breaks
1438 @item
1439 if yes, retrieves all the split objects
1440 @item
1441 checks if we are the last of the split objects
1442 @item
1443 if yes, it sets @code{extra-offset}.
1444 @end itemize
1445
1446 This procedure is installed into @internalsref{Tie}, so the last part
1447 of the broken tie is translated up.
1448
1449 @lilypond[quote,verbatim,ragged-right]
1450 #(define (my-callback grob)
1451   (let* (
1452          ; have we been split?
1453          (orig (ly:grob-original grob))
1454
1455          ; if yes, get the split pieces (our siblings)
1456          (siblings (if (ly:grob? orig)
1457                      (ly:spanner-broken-into orig) '() )))
1458
1459    (if (and (>= (length siblings) 2)
1460              (eq? (car (last-pair siblings)) grob))
1461      (ly:grob-set-property! grob 'extra-offset '(-2 . 5)))))
1462
1463 \relative c'' {
1464   \override Tie #'after-line-breaking =
1465   #my-callback
1466   c1 ~ \break c2 ~ c
1467 }
1468 @end lilypond
1469
1470 @noindent
1471 When applying this trick, the new @code{after-line-breaking} callback
1472 should also call the old one @code{after-line-breaking}, if there is
1473 one.  For example, if using this with @code{Hairpin},
1474 @code{ly:hairpin::after-line-breaking} should also be called.
1475
1476
1477 @item Some objects cannot be changed with @code{\override} for
1478 technical reasons.  Examples of those are @code{NonMusicalPaperColumn}
1479 and @code{PaperColumn}.  They can be changed with the
1480 @code{\overrideProperty} function, which works similar to @code{\once
1481 \override}, but uses a different syntax.
1482
1483 @example
1484 \overrideProperty
1485 #"Score.NonMusicalPaperColumn"  % Grob name
1486 #'line-break-system-details     % Property name
1487 #'((next-padding . 20))         % Value
1488 @end example
1489
1490 Note, however, that @code{\override}, applied to
1491 @code{NoteMusicalPaperColumn} and @code{PaperColumn}, still works as
1492 expected within @code{\context} blocks.
1493
1494 @end itemize
1495
1496
1497
1498
1499
1500
1501 @node Discussion of specific tweaks
1502 @section Discussion of specific tweaks
1503
1504 @menu
1505 * Line styles::                 
1506 * Controlling visibility of objects::  
1507 @end menu
1508
1509 @node Line styles
1510 @subsection Line styles
1511
1512 @c TODO: split the following explanations between expressive marks and
1513 @c text-related stuff. Perhaps create a new subsection named
1514 @c "Spanner limits", "Spanner boundaries"? -vv
1515
1516 Some performance indications, e.g., @i{rallentando} and
1517 @i{accelerando} and @i{trills} are written as text and are
1518 extended over many measures with lines, sometimes dotted or wavy.
1519
1520 These all use the same routines as the glissando for drawing the
1521 texts and the lines, and tuning their behavior is therefore also
1522 done in the same way.  It is done with a spanner, and the routine
1523 responsible for drawing the spanners is
1524 @code{ly:line-interface::print}.  This routine determines the
1525 exact location of the two @i{span points} and draws a line in
1526 between, in the style requested.
1527
1528 Here is an example of the different line styles available, and how
1529 to tune them.
1530
1531 @lilypond[relative=2,ragged-right,verbatim,fragment]
1532 d2 \glissando d'2
1533 \once \override Glissando #'style = #'dashed-line
1534 d,2 \glissando d'2
1535 \override Glissando #'style = #'dotted-line
1536 d,2 \glissando d'2
1537 \override Glissando #'style = #'zigzag
1538 d,2 \glissando d'2
1539 \override Glissando #'style = #'trill
1540 d,2 \glissando d'2
1541 @end lilypond
1542
1543 The information that determines the end-points is computed
1544 on-the-fly for every graphic object, but it is possible to
1545 override these. 
1546
1547 @lilypond[relative=2,ragged-right,verbatim,fragment]
1548 e2 \glissando f
1549 \once \override Glissando #'bound-details #'right #'Y = #-2
1550 e2 \glissando f
1551 @end lilypond
1552
1553 The @code{Glissando} object, like any other using the
1554 @code{ly:line-interface::print} routine, carries a nested
1555 association list.  In the above statement, the value for @code{Y}
1556 is set to @code{-2} for the association list corresponding to the
1557 right end point.  Of course, it is also possible to adjust the
1558 left side with @code{left} instead of @code{right}.
1559
1560 If @code{Y} is not set, the value is computed from the vertical
1561 position of right attachment point of the spanner. 
1562
1563 In case of a line break, the values for the span-points are
1564 extended with contents of the @code{left-broken} and
1565 @code{right-broken} sublists, for example
1566
1567 @lilypond[relative=2,ragged-right,verbatim,fragment]
1568 \override Glissando #'breakable = ##T 
1569 \override Glissando #'bound-details #'right-broken #'Y = #-3
1570 c1 \glissando \break
1571 f1
1572 @end lilypond
1573
1574 The following properties can be used for the
1575
1576 @table @code
1577 @item Y
1578 This sets the Y-coordinate of the end point, in staff space.  By
1579 default, it is the center of the bound object, so for a glissando
1580 it points to the vertical center of the note head.
1581
1582 For horizontal spanners, such as text spanner and trill spanners,
1583 it is hardcoded to 0.
1584
1585 @item attach-dir
1586 This determines where the line starts and ends in X-direction,
1587 relative to the bound object.  So, a value of @code{-1} (or
1588 @code{LEFT}) makes the line start/end at the left side of the note
1589 head it is attached to.
1590
1591 @item X
1592 This is the absolute coordinate of the end point.  It is usually
1593 computed on the fly, and there is little use in overriding it. 
1594
1595 @item stencil
1596 Line spanners may have symbols at the beginning or end, which is
1597 contained in this sub-property.  This is for internal use, it is
1598 recommended to use @code{text}.
1599
1600 @item text
1601 This is a markup that is evaluated to yield stencil.  It is used
1602 to put @i{cresc.} and @i{tr} on horizontal spanners.
1603
1604 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
1605 \override TextSpanner #'bound-details #'left #'text
1606    = \markup { \small \bold Slower }
1607 c2\startTextSpan b c a\stopTextSpan
1608 @end lilypond
1609
1610 @item stencil-align-dir-y
1611 @item stencil-offset
1612 Without setting this, the stencil is simply put there at the
1613 end-point, as defined by the @code{X} and @code{Y} sub properties.
1614 Setting either @code{stencil-align-dir-y} or @code{stencil-offset}
1615 will move the symbol at the edge relative to the end point of the
1616 line
1617
1618 @lilypond[relative=1,fragment,verbatim]
1619 \override TextSpanner #'bound-details
1620   #'left #'stencil-align-dir-y = #DOWN
1621 \override TextSpanner #'bound-details
1622   #'right #'stencil-align-dir-y = #UP
1623
1624 \override TextSpanner #'bound-details
1625   #'left #'text = #"gggg"
1626 \override TextSpanner #'bound-details
1627   #'right #'text = #"hhhh"
1628 c4^\startTextSpan c c c \stopTextSpan
1629 @end lilypond
1630
1631 @item arrow
1632 Setting this sub property to @code{#t} produce an arrowhead at the
1633 end of the line.
1634
1635 @item padding
1636 This sub property controls the space between the specified
1637 end-point of the line and the actual end.  Without padding, a
1638 glissando would start and end in the center of each note head.
1639
1640 @end table
1641
1642 FIXME: should this be in NR 3?
1643
1644 The music function \endSpanners terminates spanners and hairpins
1645 after exactly one note.
1646
1647 @lilypond[verbatim,quote,ragged-right,relative=2,fragment]
1648 \endSpanners
1649 c2 \startTextSpan c2
1650 c2 \< c2
1651 @end lilypond
1652
1653 When using \endSpanners it is not necessary to close
1654 \startTextSpan with \stopTextSpan, nor is it necessary to close
1655 hairpins with \!.
1656
1657
1658
1659 @seealso
1660
1661 Internals Reference: @internalsref{TextSpanner},
1662 @internalsref{Glissando}, @internalsref{VoiceFollower},
1663 @internalsref{TrillSpanner},
1664 @internalsref{line-spanner-interface}.
1665
1666
1667
1668 @node Controlling visibility of objects
1669 @subsection Controlling visibility of objects
1670
1671 stuff about #'break-visibility
1672