### 4.6.2 Fixing overlapping notation

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

#### The `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.

#### The `right-padding` property

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`.

#### The `staff-padding` property

`staff-padding` can be used to align objects such as dynamics along a baseline at a fixed distance from the staff, when no other notation forces them further from the staff. 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:

>     \override DynamicLineSpanner.staff-padding = #3
>     a4\f b\mf a\p b\mp

#### The `self-alignment-X` property

The following example shows how to adjust the position of a string fingering object relative to 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>

#### The `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.

#### The `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

#### The `positions` property

The `positions` property allows the vertical position and hence the slope of tuplets, slurs, phrasing slurs and beams to be controlled manually.

Here’s an example in which the phrasing slur and slur collide:

>     a8 \( ( a'16 ) a \)

One possibility would be to move the two ends of the phrasing slur higher. We can try setting the left end to 2.5 staff-spaces above the centre line and the right end to 4.5 above, and LilyPond will select the phrasing slur from the candidates it has found with its end points closest to these:

>     \once \override PhrasingSlur.positions = #'(2.5 . 4.5)
>     a8 \( ( a'16 ) a \)

This is an improvement, but why not lower the right end of the slur a little? If you try it you’ll find it can’t be done in this way. That’s because there are no candidate slurs lower than the one already selected, and in this case the `positions` property has no effect. However, ties, slurs and phrasing slurs can be positioned and shaped very precisely when necessary. To learn how to do this, see Modifying ties and slurs.

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.

#### The `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 }
>         \\
>         { <ees, c>2 des }
>         \\
>         \\
>         { aes'2 f4 fes }
>       >> |
>       <c ees aes c>1 |
>     }

The inner note of the first chord (i.e. the A-flat in the fourth Voice) need not be shifted away from the note column of the higher note. We might expect to correct this by using `\shiftOff`, but this will cause warnings about clashing note columns. Instead, we set `force-hshift`, which is a property of `NoteColumn`, of this note to zero.

In the second chord we prefer the F to line up with the A-flat and the lowest note to be positioned slightly right to avoid a collision of stems. We achieve this by setting `force-hshift` in the `NoteColumn` of the low D-flat to move it to the right by half a staff-space, and setting `force-hshift` for the F to zero. Note that we use `\once` to avoid the settings propagating beyond the immediate musical moment, although in this small example the `\once` and the second `\override` in Voice four could be omitted. This would not be good practice.

Here’s the final result:

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

其他语言：česky, deutsch, español, français, italiano, 日本語, nederlands。
About automatic language selection.

#### LilyPond — Learning Manual v2.18.2 (稳定分支).