LilyPond Learning Manual: 4.5.2 Fixing overlapping notation

### 4.5.2 Fixing overlapping notation

Let’s now see how the properties in the previous section can help to resolve overlapping notation.

### padding property

The `padding` property can be set to increase (or decrease) the distance between symbols that are printed above or below notes.

>     c2\fermata
>     \override Script #'padding = #3
>     b2\fermata

>     % This will not work, see below
>     \override MetronomeMark #'padding = #3
>     \tempo 4 = 120
>     c1 |
>     % This works
>     \override Score.MetronomeMark #'padding = #3
>     \tempo 4 = 80
>     d1 |

Note in the second example how important it is to figure out what context handles a certain object. Since the `MetronomeMark` object is handled in the `Score` context, property changes in the `Voice` context will not be noticed. For more details, see Modifying properties.

If the `padding` property of an object is increased when that object is in a stack of objects being positioned according to their `outside-staff-priority`, then that object and all objects outside it are moved.

### right-padding

The `right-padding` property affects the spacing between the accidental and the note to which it applies. It is not often required, but the default spacing may be wrong for certain special accidental glyphs or combination of glyphs used in some microtonal music. These have to be entered by overriding the accidental stencil with a markup containing the desired symbol(s), like this:

>     sesquisharp = \markup { \sesquisharp }
>     \relative c'' {
>       c4
>       % This prints a sesquisharp but the spacing is too small
>       \once \override Accidental
>         #'stencil = #ly:text-interface::print
>       \once \override Accidental #'text = #sesquisharp
>       cis4 c
>       % This improves the spacing
>       \once \override Score.AccidentalPlacement #'right-padding = #0.6
>       \once \override Accidental
>         #'stencil = #ly:text-interface::print
>       \once \override Accidental #'text = #sesquisharp
>       cis4 |
>     }

This necessarily uses an override for the accidental stencil which will not be covered until later. The stencil type must be a procedure, here changed to print the contents of the `text` property of `Accidental`, which itself is set to be a sesquisharp sign. This sign is then moved further away from the note head by overriding `right-padding`.

### staff-padding property

`staff-padding` can be used to align objects such as dynamics along a baseline at a fixed height above the staff, rather than at a height dependent on the position of the note to which they are attached. It is not a property of `DynamicText` but of `DynamicLineSpanner`. This is because the baseline should apply equally to all dynamics, including those created as extended spanners. So this is the way to align the dynamic marks in the example taken from the previous section:

>     \dynamicUp
>     % Extend width by 1 unit
>     \override DynamicText #'extra-spacing-width = #'(-0.5 . 0.5)
>     % Align dynamics to a base line 2 units above staff
>     \override DynamicLineSpanner #'staff-padding = #2
>     a4\f b\mf c\mp b\p

### self-alignment-X property

The following example shows how this can resolve the collision of a string fingering object with a note’s stem by aligning the right edge with the reference point of the parent note:

>     \voiceOne
>     <a\2>
>     \once \override StringNumber #'self-alignment-X = #RIGHT
>     <a\2>

### staff-position property

Multimeasure rests in one voice can collide with notes in another. Since these rests are typeset centered between the bar lines, it would require significant effort for LilyPond to figure out which other notes might collide with it, since all the current collision handling between notes and between notes and rests is done only for notes and rests that occur at the same time. Here’s an example of a collision of this type:

>     << { c4 c c c } \\ { R1 } >>

The best solution here is to move the multimeasure rest down, since the rest is in voice two. The default in `\voiceTwo` (i.e. in the second voice of a `<<{...} \\ {...}>>` construct) is that `staff-position` is set to -4 for MultiMeasureRest, so we need to move it, say, four half-staff spaces down to `-8`.

>     <<
>       { c4 c c c }
>       \\
>       \override MultiMeasureRest #'staff-position = #-8
>       { R1 }
>     >>

This is better than using, for example, `extra-offset`, because the ledger line above the rest is inserted automatically.

### extra-offset property

The `extra-offset` property provides complete control over the positioning of an object both horizontally and vertically.

In the following example, the second fingering is moved a little to the left, and 1.8 staff space downwards:

>     \stemUp
>     f4-5
>     \once \override Fingering #'extra-offset = #'(-0.3 . -1.8)
>     f4-5

### positions property

The `positions` property allows the position and slope of tuplets, slurs, phrasing slurs and beams to be controlled manually. Here’s an example which has an ugly phrasing slur due to its trying to avoid the slur on the acciaccatura.

>     r4 \acciaccatura e8\( d8 c~ c d c d\)

We could simply move the phrasing slur above the notes, and this would be the preferred solution:

>     r4
>     \phrasingSlurUp
>     \acciaccatura e8\( d8 c~ c d c d\)

But if there were some reason why this could not be done the other alternative would be to move the left end of the phrasing slur down a little using the `positions` property. This also resolves the rather nasty shape.

>     r4
>     \once \override PhrasingSlur #'positions = #'(-4 . -3)
>     \acciaccatura e8\( d8 c~ c d c d\)

Here’s a further example. We see that the beams collide with the ties:

>     {
>       \time 4/2
>       <<
>         { c'1 ~ c'2. e'8 f' }
>         \\
>         { e''8 e'' e'' e''  e'' e'' e'' e''  f''2 g'' }
>       >>
>       <<
>         { c'1 ~ c'2. e'8 f' }
>         \\
>         { e''8 e'' e'' e''  e'' e'' e'' e''  f''2 g'' }
>       >>
>     }

This can be resolved by manually moving both ends of the beam up from their position at 1.81 staff-spaces below the center line to, say, 1:

>     {
>       \time 4/2
>       <<
>         { c'1 ~ c'2. e'8 f' }
>         \\
>         {
>           \override Beam #'positions = #'(-1 . -1)
>           e''8 e'' e'' e''  e'' e'' e'' e''  f''2 g''
>         }
>       >>
>       <<
>         { c'1 ~ c'2. e'8 f' }
>         \\
>         { e''8 e'' e'' e''  e'' e'' e'' e''  f''2 g'' }
>       >>
>     }

Note that the override continues to apply in the first voice of the second measure of eighth notes, but not to any of the beams in the second voice.

### force-hshift property

We can now see how to apply the final corrections to the Chopin example introduced at the end of I’m hearing Voices, which was left looking like this:

>     \new Staff \relative c'' {
>       \key aes \major
>       <<
>         { c2 aes4. bes8 }
>         \\
>         { aes2 f4 fes }
>         \\
>         {
>           \voiceFour
>           <ees c>2 des
>         }
>       >> |
>       <c ees aes c>1 |
>     }

The lower two notes of the first chord (i.e, those in the third voice) should not be shifted away from the note column of the higher two notes. To correct this we set `force-hshift`, which is a property of `NoteColumn`, of these notes to zero. The lower note of the second chord is best placed just to the right of the higher notes. We achieve this by setting `force-hshift` of this note to 0.5, ie half a note head’s width to the right of the note column of the higher notes.

Here’s the final result:

>     \new Staff \relative c'' {
>       \key aes \major
>       <<
>         { c2 aes4. bes8 }
>         \\
>         { aes2 f4 fes }
>         \\
>         {
>           \voiceFour
>           \once \override NoteColumn #'force-hshift = #0
>           <ees c>2
>           \once \override NoteColumn #'force-hshift = #0.5
>           des2
>         }
>       >> |
>       <c ees aes c>1 |
>     }

Más nyelvek: česky, deutsch, español, français, italiano, 日本語, nederlands.

#### LilyPond — Learning Manual