1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @node Changing defaults
3 @chapter Changing defaults
6 The purpose of LilyPond's design is to provide the finest output
7 quality as a default. Nevertheless, it may happen that you need to
8 change this default layout. The layout is controlled through a large
9 number of proverbial ``knobs and switches.'' This chapter does not
10 list each and every knob. Rather, it outlines what groups of controls
11 are available and explains how to lookup which knob to use for a
15 @cindex Program reference
17 The controls available for tuning are described in a separate
23 @ref{Top,Program reference,,lilypond-internals}.
26 lists all different variables, functions and options available in
27 LilyPond. It is written as a HTML document, which is available
28 @uref{http://@/lilypond@/.org/@/doc/@/v2.7/@/Documentation/@/user/@/lilypond@/-internals/,on@/-line},
29 but is also included with the LilyPond documentation package.
31 There are three areas where the default settings may be changed:
35 Output: changing the appearance of individual
36 objects. For example, changing stem directions or the location of
40 Context: changing aspects of the translation from music events to
41 notation. For example, giving each staff a separate time signature.
44 Global layout: changing the appearance of the spacing, line
45 breaks, and page dimensions.
48 Then there are separate systems for typesetting text (like
49 @emph{ritardando}) and selecting different fonts. This chapter also
52 Internally, LilyPond uses Scheme (a LISP dialect) to provide
53 infrastructure. Overriding layout decisions in effect accesses the
54 program internals, which requires Scheme input. Scheme elements are
55 introduced in a @code{.ly} file with the hash mark
56 @code{#}.@footnote{@ref{Scheme tutorial} contains a short tutorial
57 on entering numbers, lists, strings, and symbols in Scheme.}
61 * Interpretation contexts::
62 * The \override command::
66 @node Interpretation contexts
67 @section Interpretation contexts
69 When music is printed, a lot of notational elements must be added to the
70 input, which is often bare bones. For example, compare the input and
71 output of the following example:
73 @lilypond[quote,verbatim,relative=2,fragment]
77 The input is rather sparse, but in the output, bar lines, accidentals,
78 clef, and time signature are added. LilyPond @emph{interprets} the
79 input. During this step, the musical information is inspected in time
80 order, similar to reading a score from left to right. While reading,
81 the input, the program remembers where measure boundaries are, and what
82 pitches need explicit accidentals. This information can be presented on
83 several levels. For example, the effect of an accidental is limited
84 to a single staff, while a bar line must be synchronized across the
87 Within LilyPond, these rules and bits of information are grouped in
88 so-called Contexts. Examples of context are @context{Voice},
89 @context{Staff}, and @context{Score}. They are hierarchical, for
90 example, a @context{Staff} can contain many @context{Voice}s, and a
91 @context{Score} can contain many @context{Staff} contexts.
93 Each context has the responsibility for enforcing some notation rules,
94 creating some notation objects and maintaining the associated
95 properties. So, the synchronization of bar lines is handled at
96 @context{Score} context. The @context{Voice} may introduce an
97 accidental and then the @context{Staff} context maintains the rule to
98 show or suppress the accidental for the remainder of the measure.
100 For simple scores, contexts are created implicitly, and you need not
101 be aware of them. For larger pieces, such as piano music, they must be
102 created explicitly to make sure that you get as many staves as you
103 need, and that they are in the correct order. For typesetting pieces
104 with specialized notation, it can be useful to modify existing or
105 to define new contexts.
108 A complete description of all available contexts is in the program
111 @internalsref{Contexts}.
114 Translation @arrow{} Context.
117 @c [TODO: describe propagation]
121 * Creating contexts::
122 * Changing context properties on the fly::
123 * Modifying context plug-ins::
124 * Layout tunings within contexts::
125 * Changing context default settings::
126 * Defining new contexts::
129 @node Creating contexts
130 @subsection Creating contexts
132 For scores with only one voice and one staff, correct contexts are
133 created automatically. For more complex scores, it is necessary to
134 create them by hand. There are three commands that do this.
136 The easiest command is @code{\new}, and it also the quickest to type.
137 It is prepended to a music expression, for example
141 @cindex Context, creating
144 \new @var{type} @var{music expression}
148 where @var{type} is a context name (like @code{Staff} or
149 @code{Voice}). This command creates a new context, and starts
150 interpreting the @var{music expression} with that.
152 A practical application of @code{\new} is a score with many
153 staves. Each part that should be on its own staff, is preceded with
156 @lilypond[quote,verbatim,relative=2,ragged-right,fragment]
157 << \new Staff { c4 c }
162 The @code{\new} command may also give a name to the context,
165 \new @var{type} = @var{id} @var{music}
167 However, this user specified name is only used if there is no other
168 context already earlier with the same name.
170 @cindex @code{\context}
172 Like @code{\new}, the @code{\context} command also directs a music
173 expression to a context object, but gives the context an explicit name. The
177 \context @var{type} = @var{id} @var{music}
180 This form will search for an existing context of type @var{type}
181 called @var{id}. If that context does not exist yet, the result is
182 identical to @code{\new} @var{type} = @var{id} @var{music}, i.e.
183 a new context with the specified name is created.
184 This is useful if the context is referred to later on. For example, when
185 setting lyrics the melody is in a named context
188 \context Voice = "@b{tenor}" @var{music}
192 so the texts can be properly aligned to its notes,
195 \new Lyrics \lyricsto "@b{tenor}" @var{lyrics}
200 Another possibility is funneling two different music expressions into
201 one context. In the following example, articulations and notes are
206 arts = @{ s4-. s4-> @}
209 They are combined by sending both to the same @context{Voice} context,
212 << \new Staff \context Voice = "A" \music
213 \context Voice = "A" \arts
216 @lilypond[quote,ragged-right]
220 \new Staff \context Voice = "A" \music
221 \context Voice = "A" \arts
225 With this mechanism, it is possible to define an Urtext (original
226 edition), with the option to put several distinct articulations on the
229 @cindex creating contexts
231 The third command for creating contexts is
233 \context @var{type} @var{music}
238 This is similar to @code{\context} with @code{= @var{id}}, but matches
239 any context of type @var{type}, regardless of its given name.
241 This variant is used with music expressions that can be interpreted at
242 several levels. For example, the @code{\applyOutput} command (see
243 @ref{Running a function on all layout objects}). Without an explicit
244 @code{\context}, it is usually applied to @context{Voice}
247 \applyOutput #@var{function} % apply to Voice
250 To have it interpreted at the @context{Score} or @context{Staff} level use
254 \context Score \applyOutput #@var{function}
255 \context Staff \applyOutput #@var{function}
259 @node Changing context properties on the fly
260 @subsection Changing context properties on the fly
264 @cindex changing properties
266 Each context can have different @emph{properties}, variables contained
267 in that context. They can be changed during the interpretation step.
268 This is achieved by inserting the @code{\set} command in the music,
271 \set @var{context}.@var{prop} = #@var{value}
275 @lilypond[quote,verbatim,relative=2,fragment]
277 \set Score.skipBars = ##t
281 This command skips measures that have no notes. The result is that
282 multi-rests are condensed. The value assigned is a Scheme object. In
283 this case, it is @code{#t}, the boolean True value.
285 If the @var{context} argument is left out, then the current bottom-most
286 context (typically @context{ChordNames}, @context{Voice}, or
287 @context{Lyrics}) is used. In this example,
289 @lilypond[quote,verbatim,relative=2,fragment]
291 \set autoBeaming = ##f
296 the @var{context} argument to @code{\set} is left out, so automatic
297 beaming is switched off in the current @internalsref{Voice}. Note that
298 the bottom-most context does not always contain the property that you
299 wish to change -- for example, attempting to set the @code{skipBars}
300 property (of the bottom-most context, in this case @code{Voice}) will
303 @lilypond[quote,verbatim,relative=2,fragment]
309 Contexts are hierarchical, so if a bigger context was specified, for
310 example @context{Staff}, then the change would also apply to all
311 @context{Voice}s in the current stave. The change is applied
312 `on-the-fly', during the music, so that the setting only affects the
313 second group of eighth notes.
315 @cindex @code{\unset}
317 There is also an @code{\unset} command,
319 \unset @var{context}.@var{prop}
323 which removes the definition of @var{prop}. This command removes
324 the definition only if it is set in @var{context}, so
327 \set Staff.autoBeaming = ##f
331 introduces a property setting at @code{Staff} level. The setting also
332 applies to the current @code{Voice}. However,
335 \unset Voice.autoBeaming
339 does not have any effect. To cancel this setting, the @code{\unset}
340 must be specified on the same level as the original @code{\set}. In
341 other words, undoing the effect of @code{Staff.autoBeaming = ##f}
344 \unset Staff.autoBeaming
347 Like @code{\set}, the @var{context} argument does not have to be
348 specified for a bottom context, so the two statements
351 \set Voice.autoBeaming = ##t
352 \set autoBeaming = ##t
360 Settings that should only apply to a single time-step can be entered
361 with @code{\once}, for example in
363 @lilypond[quote,verbatim,relative=2,fragment]
365 \once \set fontSize = #4.7
370 the property @code{fontSize} is unset automatically after the second
373 A full description of all available context properties is in the
374 program reference, see
376 @internalsref{Tunable context properties}.
379 Translation @arrow{} Tunable context properties.
383 @node Modifying context plug-ins
384 @subsection Modifying context plug-ins
386 Notation contexts (like Score and Staff) not only store properties,
387 they also contain plug-ins, called ``engravers'' that create notation
388 elements. For example, the Voice context contains a
389 @code{Note_head_engraver} and the Staff context contains a
390 @code{Key_signature_engraver}.
392 For a full a description of each plug-in, see
394 @internalsref{Engravers}.
397 Program reference @arrow Translation @arrow{} Engravers.
399 Every context described in
401 @internalsref{Contexts}
404 Program reference @arrow Translation @arrow{} Context.
406 lists the engravers used for that context.
409 It can be useful to shuffle around these plug-ins. This is done by
410 starting a new context, with @code{\new} or @code{\context}, and
411 modifying it like this,
416 \new @var{context} \with @{
427 where the @dots{} should be the name of an engraver. Here is a simple
428 example which removes @code{Time_signature_engraver} and
429 @code{Clef_engraver} from a @code{Staff} context,
431 @lilypond[quote,relative=1,verbatim,fragment]
436 \remove "Time_signature_engraver"
437 \remove "Clef_engraver"
444 In the second staff there are no time signature or clef symbols. This
445 is a rather crude method of making objects disappear since it will affect
446 the entire staff. The spacing is adversely influenced too. A more
447 sophisticated method of blanking objects is shown in @ref{Common tweaks}.
449 The next example shows a practical application. Bar lines and time
450 signatures are normally synchronized across the score. This is done
451 by the @code{Timing_translator} and @code{Default_bar_line_engraver}.
452 This plug-in keeps an administration of time signature, location
453 within the measure, etc. By moving thes engraver from @code{Score} to
454 @code{Staff} context, we can have a score where each staff has its own
457 @cindex polymetric scores
458 @cindex Time signatures, multiple
460 @lilypond[quote,relative=1,ragged-right,verbatim,fragment]
462 \remove "Timing_translator"
463 \remove "Default_bar_line_engraver"
466 \consists "Timing_translator"
467 \consists "Default_bar_line_engraver"
473 \consists "Timing_translator"
474 \consists "Default_bar_line_engraver"
483 @node Layout tunings within contexts
484 @subsection Layout tunings within contexts
486 Each context is responsible for creating certain types of graphical
487 objects. The settings used for printing these objects are also stored by
488 context. By changing these settings, the appearance of objects can be
491 The syntax for this is
494 \override @var{context}.@var{name} #'@var{property} = #@var{value}
497 Here @var{name} is the name of a graphical object, like @code{Stem} or
498 @code{NoteHead}, and @var{property} is an internal variable of the
499 formatting system (`grob property' or `layout property'). The latter is a
500 symbol, so it must be quoted. The subsection @ref{Constructing a
501 tweak} explains what to fill in for @var{name}, @var{property}, and
502 @var{value}. Here we only discuss the functionality of this command.
507 \override Staff.Stem #'thickness = #4.0
511 makes stems thicker (the default is 1.3, with staff line thickness as a
512 unit). Since the command specifies @context{Staff} as context, it only
513 applies to the current staff. Other staves will keep their normal
514 appearance. Here we see the command in action:
516 @lilypond[quote,verbatim,relative=2,fragment]
518 \override Staff.Stem #'thickness = #4.0
524 The @code{\override} command changes the definition of the @code{Stem}
525 within the current @context{Staff}. After the command is interpreted
526 all stems are thickened.
528 Analogous to @code{\set}, the @var{context} argument may be left out,
529 causing it to default to @context{Voice}, and adding @code{\once} applies
530 the change during one timestep only
532 @lilypond[quote,fragment,verbatim,relative=2]
534 \once \override Stem #'thickness = #4.0
539 The @code{\override} must be done before the object is
540 started. Therefore, when altering @emph{Spanner} objects, like slurs or
541 beams, the @code{\override} command must be executed at the moment when
542 the object is created. In this example,
545 @lilypond[quote,fragment,verbatim,relative=2]
546 \override Slur #'thickness = #3.0
548 \override Beam #'thickness = #0.6
553 the slur is fatter but the beam is not. This is because the command for
554 @code{Beam} comes after the Beam is started. Therefore it has no effect.
556 Analogous to @code{\unset}, the @code{\revert} command for a context
557 undoes an @code{\override} command; like with @code{\unset}, it only
558 affects settings that were made in the same context. In other words, the
559 @code{\revert} in the next example does not do anything.
562 \override Voice.Stem #'thickness = #4.0
563 \revert Staff.Stem #'thickness
566 Some tweakable options are called ``subproperties'' and reside inside
567 properties. To tweak those, use
570 \override Stem #'details #'beamed-lengths = #'(4 4 3)
576 Internals: @internalsref{OverrideProperty}, @internalsref{RevertProperty},
577 @internalsref{PropertySet}, @internalsref{Backend}, and
578 @internalsref{All layout objects}.
583 The back-end is not very strict in type-checking object properties.
584 Cyclic references in Scheme values for properties can cause hangs
588 @node Changing context default settings
589 @subsection Changing context default settings
591 The adjustments of the previous subsections (@ref{Changing context
592 properties on the fly}, @ref{Modifying context plug-ins}, and
593 @ref{Layout tunings within contexts}) can also be entered separately
594 from the music, in the @code{\layout} block,
603 \override Stem #'thickness = #4.0
604 \remove "Time_signature_engraver"
615 takes the existing definition for context @context{Staff} from the
616 identifier @code{\Staff}.
621 \override Stem #'thickness = #4.0
622 \remove "Time_signature_engraver"
626 affect all staves in the score.
628 Other contexts can be modified analogously.
630 The @code{\set} keyword is optional within the @code{\layout} block, so
646 It is not possible to collect context changes in a variable, and apply
647 them to one @code{\context} definition by referring to that variable.
649 The @code{\RemoveEmptyStaffContext} will override your current
650 @code{\Staff} variable. If you wish to change the defaults for a
651 staff that uses @code{\RemoveEmptyStaffContext}, you must do so
652 after calling @code{\RemoveemptyStaffContext}, ie
657 \RemoveEmptyStaffContext
659 \override Stem #'thickness = #4.0
665 @node Defining new contexts
666 @subsection Defining new contexts
668 Specific contexts, like @context{Staff} and @code{Voice}, are made of
669 simple building blocks, and it is possible to compose engraver
670 plug-ins in different combinations, thereby creating new types of
673 The next example shows how to build a different type of
674 @context{Voice} context from scratch. It will be similar to
675 @code{Voice}, but prints centered slash noteheads only. It can be used
676 to indicate improvisation in Jazz pieces,
678 @lilypond[quote,ragged-right]
681 \type "Engraver_group"
682 \consists "Note_heads_engraver"
683 \consists "Text_engraver"
684 \consists Pitch_squash_engraver
685 squashedPosition = #0
686 \override NoteHead #'style = #'slash
687 \override Stem #'transparent = ##t
691 \accepts "ImproVoice"
695 a4 d8 bes8 \new ImproVoice { c4^"ad lib" c
696 c4 c^"undress" c_"while playing :)" c }
702 These settings are again done within a @code{\context} block inside a
703 @code{\layout} block,
713 In the following discussion, the example input shown should go on the
714 @dots{} in the previous fragment.
716 First, the context gets a name. Instead of @context{Voice} it
717 will be called @context{ImproVoice},
723 Since it is similar to the @context{Voice}, we want commands that work
724 on (existing) @context{Voice}s to remain working. This is achieved by
725 giving the new context an alias @context{Voice},
731 The context will print notes, and instructive texts
734 \consists Note_heads_engraver
735 \consists Text_engraver
738 but only on the center line,
741 \consists Pitch_squash_engraver
742 squashedPosition = #0
745 The @internalsref{Pitch_squash_engraver} modifies note heads (created
746 by @internalsref{Note_heads_engraver}) and sets their vertical
747 position to the value of @code{squashedPosition}, in this case@tie{}@code{0},
750 The notes look like a slash, without a stem,
753 \override NoteHead #'style = #'slash
754 \override Stem #'transparent = ##t
758 All these plug-ins have to cooperate, and this is achieved with a
759 special plug-in, which must be marked with the keyword @code{\type}.
760 This should always be @internalsref{Engraver_group},
763 \type "Engraver_group"
771 \type "Engraver_group"
772 \consists "Note_heads_engraver"
773 \consists "Text_engraver"
774 \consists Pitch_squash_engraver
775 squashedPosition = #0
776 \override NoteHead #'style = #'slash
777 \override Stem #'transparent = ##t
782 Contexts form hierarchies. We want to hang the @context{ImproVoice}
783 under @context{Staff}, just like normal @code{Voice}s. Therefore, we
784 modify the @code{Staff} definition with the @code{\accepts}
785 command,@footnote{The opposite of @code{\accepts} is @code{\denies},
786 which is sometimes needed when reusing existing context definitions.}
797 Putting both into a @code{\layout} block, like
807 \accepts "ImproVoice"
812 Then the output at the start of this subsection can be entered as
820 c c_"while playing :)"
829 @node The \override command
830 @section The \override command
832 In the previous section, we have already touched on a command that
833 changes layout details: the @code{\override} command. In this section,
834 we will look in more detail at how to use the command in practice.
835 First, we will give a few versatile commands that are sufficient
836 for many situations. The next section will discuss the general use of
841 * Constructing a tweak::
842 * Navigating the program reference::
843 * Layout interfaces::
844 * Determining the grob property::
845 * Objects connected to the input::
851 @node Constructing a tweak
852 @subsection Constructing a tweak
854 The general procedure of changing output, that is, entering
858 \override Voice.Stem #'thickness = #3.0
862 means that we have to determine these bits of information:
865 @item the context: here @context{Voice}.
866 @item the layout object: here @code{Stem}.
867 @item the layout property: here @code{thickness}
868 @item a sensible value: here @code{3.0}
872 @cindex internal documentation
873 @cindex finding graphical objects
874 @cindex graphical object descriptions
876 @cindex @code{\override}
877 @cindex internal documentation
879 We demonstrate how to glean this information from the notation manual
880 and the program reference.
882 @node Navigating the program reference
883 @subsection Navigating the program reference
885 Suppose we want to move the fingering indication in the fragment
888 @lilypond[quote,fragment,relative=2,verbatim]
894 If you visit the documentation on fingering instructions (in
895 @ref{Fingering instructions}), you will notice that there is written:
900 Program reference: @internalsref{FingerEvent} and @internalsref{Fingering}.
906 This fragment points to two parts of the program reference: a page
907 on @code{FingerEvent} and one on @code{Fingering}.
909 The page on @code{FingerEvent} describes the properties of the music
910 expression for the input @code{-2}. The page contains many links
911 forward. For example, it says
914 Accepted by: @internalsref{Fingering_engraver},
918 That link brings us to the documentation for the Engraver, the
922 This engraver creates the following layout objects: @internalsref{Fingering}.
925 In other words, once the @code{FingerEvent}s are interpreted, the
926 @code{Fingering_engraver} plug-in will process them.
929 @c I can't figure out what this is supposed to mean. -gp
931 The @code{Fingering_engraver} is also listed to create
932 @internalsref{Fingering} objects,
934 @c old info? it doesn't make any sense to me with our current docs.
936 second bit of information listed under @b{See also} in the Notation
940 By clicking around in the program reference, we can follow the
941 flow of information within the program, either forward (like we did
942 here), or backwards, following links like this:
946 @item @internalsref{Fingering}:
947 @internalsref{Fingering} objects are created by:
948 @b{@internalsref{Fingering_engraver}}
950 @item @internalsref{Fingering_engraver}:
951 Music types accepted: @b{@internalsref{fingering-event}}
953 @item @internalsref{fingering-event}:
954 Music event type @code{fingering-event} is in Music expressions named
955 @b{@internalsref{FingerEvent}}
958 This path goes against the flow of information in the program: it
959 starts from the output, and ends at the input event.
961 The program reference can also be browsed like a normal document. It
962 contains a chapter on
964 @internalsref{Music definitions},
967 @code{Music definitions}
969 on @internalsref{Translation}, and the @internalsref{Backend}. Every
970 chapter lists all the definitions used, and all properties that may be
974 @node Layout interfaces
975 @subsection Layout interfaces
977 @cindex interface, layout
978 @cindex layout interface
981 The HTML page that we found in the previous section, describes the
982 layout object called @internalsref{Fingering}. Such an object is a
983 symbol within the score. It has properties that store numbers (like
984 thicknesses and directions), but also pointers to related objects. A
985 layout object is also called a @emph{Grob}, which is short for Graphical
986 Object. For more details about Grobs, see @internalsref{grob-interface}.
988 The page for @code{Fingering} lists the definitions for the
989 @code{Fingering} object. For example, the page says
992 @code{padding} (dimension, in staff space):
998 which means that the number will be kept at a distance of at least 0.6
1002 Each layout object may have several functions as a notational or
1003 typographical element. For example, the Fingering object
1004 has the following aspects
1008 Its size is independent of the horizontal spacing, unlike slurs or beams.
1011 It is a piece of text. Granted, it is usually a very short text.
1014 That piece of text is typeset with a font, unlike slurs or beams.
1017 Horizontally, the center of the symbol should be aligned to the
1018 center of the notehead.
1021 Vertically, the symbol is placed next to the note and the staff.
1024 The vertical position is also coordinated with other super- and subscript
1028 Each of these aspects is captured in so-called @emph{interface}s,
1029 which are listed on the @internalsref{Fingering} page at the bottom
1032 This object supports the following interfaces:
1033 @internalsref{item-interface},
1034 @internalsref{self-alignment-interface},
1035 @internalsref{side-position-interface}, @internalsref{text-interface},
1036 @internalsref{text-script-interface}, @internalsref{font-interface},
1037 @internalsref{finger-interface}, and @internalsref{grob-interface}.
1040 Clicking any of the links will take you to the page of the respective
1041 object interface. Each interface has a number of properties. Some of
1042 them are not user-serviceable (``Internal properties''), but others
1045 We have been talking of @emph{the} @code{Fingering} object, but actually it
1046 does not amount to much. The initialization file
1047 @file{scm/@/define@/-grobs@/.scm} shows the soul of the `object',
1052 (avoid-slur . around)
1053 (slur-padding . 0.2)
1054 (staff-padding . 0.5)
1055 (self-alignment-X . 0)
1056 (self-alignment-Y . 0)
1057 (script-priority . 100)
1058 (stencil . ,ly:text-interface::print)
1059 (direction . ,ly:script-interface::calc-direction)
1060 (font-encoding . fetaNumber)
1061 (font-size . -5) ; don't overlap when next to heads.
1062 (meta . ((class . Item)
1063 (interfaces . (finger-interface
1065 text-script-interface
1067 side-position-interface
1068 self-alignment-interface
1069 item-interface))))))
1073 As you can see, the @code{Fingering} object is nothing more than a
1074 bunch of variable settings, and the webpage in the Program Reference
1075 is directly generated from this definition.
1077 @node Determining the grob property
1078 @subsection Determining the grob property
1081 Recall that we wanted to change the position of the @b{2} in
1083 @lilypond[quote,fragment,relative=2,verbatim]
1089 Since the @b{2} is vertically positioned next to its note, we have to
1090 meddle with the interface associated with this positioning. This is
1091 done using @code{side-position-interface}. The page for this interface
1095 @code{side-position-interface}
1097 Position a victim object (this one) next to other objects (the
1098 support). The property @code{direction} signifies where to put the
1099 victim object relative to the support (left or right, up or down?)
1104 below this description, the variable @code{padding} is described as
1109 (dimension, in staff space)
1111 Add this much extra space between objects that are next to each other.
1115 By increasing the value of @code{padding}, we can move away the
1116 fingering. The following command inserts 3 staff spaces of white
1117 between the note and the fingering:
1119 \once \override Voice.Fingering #'padding = #3
1122 Inserting this command before the Fingering object is created,
1123 i.e., before @code{c2}, yields the following result:
1125 @lilypond[quote,relative=2,fragment,verbatim]
1126 \once \override Voice.Fingering #'padding = #3
1133 In this case, the context for this tweak is @context{Voice}. This
1134 fact can also be deduced from the program reference, for the page for
1135 the @internalsref{Fingering_engraver} plug-in says
1138 Fingering_engraver is part of contexts: @dots{} @b{@internalsref{Voice}}
1141 @node Objects connected to the input
1142 @subsection Objects connected to the input
1144 In some cases, it is possible to take a short-cut for tuning graphical
1145 objects. For objects that result directly from a piece of the input,
1146 you can use the @code{\tweak} function, for example
1148 @lilypond[relative=2,fragment,verbatim,ragged-right]
1151 \tweak #'color #red d
1153 \tweak #'duration-log #1 a
1154 >4-\tweak #'padding #10 -.
1157 As you can see, properties are set directly in the objects directly,
1158 without mentioning the grob name or context where this should be
1161 This technique only works for objects that are directly connected to
1162 an @internalsref{event} from the input, for example
1165 @item note heads, caused by chord-pitch.
1166 @item articulation signs, caused by articulation instructions
1169 It notably does not work for stems and accidentals (these are caused
1170 by note heads, not by music events) or clefs (these are not caused by
1171 music inputs, but rather by the change of a property value).
1174 @node Difficult tweaks
1175 @subsection Difficult tweaks
1177 There are a few classes of difficult adjustments.
1183 One type of difficult adjustment is the appearance of spanner objects,
1184 such as slur and tie. Initially, only one of these objects is created,
1185 and they can be adjusted with the normal mechanism. However, in some
1186 cases the spanners cross line breaks. If this happens, these objects
1187 are cloned. A separate object is created for every system that it is
1188 in. These are clones of the original object and inherit all
1189 properties, including @code{\override}s.
1192 In other words, an @code{\override} always affects all pieces of a
1193 broken spanner. To change only one part of a spanner at a line break,
1194 it is necessary to hook into the formatting process. The
1195 @code{after-line-breaking} callback contains the Scheme procedure that
1196 is called after the line breaks have been determined, and layout
1197 objects have been split over different systems.
1199 In the following example, we define a procedure
1200 @code{my-callback}. This procedure
1204 determines if we have been split across line breaks
1206 if yes, retrieves all the split objects
1208 checks if we are the last of the split objects
1210 if yes, it sets @code{extra-offset}.
1213 This procedure is installed into @internalsref{Tie}, so the last part
1214 of the broken tie is translated up.
1216 @lilypond[quote,verbatim,ragged-right]
1217 #(define (my-callback grob)
1219 ; have we been split?
1220 (orig (ly:grob-original grob))
1222 ; if yes, get the split pieces (our siblings)
1223 (siblings (if (ly:grob? orig)
1224 (ly:spanner-broken-into orig) '() )))
1226 (if (and (>= (length siblings) 2)
1227 (eq? (car (last-pair siblings)) grob))
1228 (ly:grob-set-property! grob 'extra-offset '(-2 . 5)))))
1231 \override Tie #'after-line-breaking =
1238 When applying this trick, the new @code{after-line-breaking} callback
1239 should also call the old one @code{after-line-breaking}, if there is
1240 one. For example, if using this with @code{Hairpin},
1241 @code{ly:hairpin::after-line-breaking} should also be called.
1244 @item Some objects cannot be changed with @code{\override} for
1245 technical reasons. Examples of those are @code{NonMusicalPaperColumn}
1246 and @code{PaperColumn}. They can be changed with the
1247 @code{\outputProperty} function, which works similar to @code{\once
1248 \override}, but uses a different syntax,
1252 #"Score.NonMusicalPaperColumn" % Grob name
1253 #'line-break-system-details % Property name
1254 #'((next-padding . 20)) % Value