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

c'2\fermata
\override Script.padding = #3
b2\fermata

[image of music]

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

[image of music]

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''4
  % 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 |
}

[image of music]

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
\relative { a'4\f b\mf a\p b\mp }

[image of music]


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>

[image of music]


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:

<< \relative { c'4 c c c } \\ { R1 } >>

[image of music]

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 -6 for MultiMeasureRest, so we need to move it, say, four half-staff spaces down to -10.

<<
  \relative { c'4 c c c }
  \\
  \override MultiMeasureRest.staff-position = #-10
  { R1 }
>>

[image of music]

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

See Engraving ties manually for the difference between exact and inexact values.


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:

f'4-5
\once \override Fingering.extra-offset = #'(-0.3 . -1.8)
f'4-5

[image of music]


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:

\relative { a'8 \( ( a'16 ) a \) }

[image of music]

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 center 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)
a'8 \( ( a''16 ) a'' \)

[image of music]

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
  <<
    \relative { c'1~ 2. e8 f }
    \\
    \relative {
      e''8 e e e
      e e e e
      f2 g
    }
  >>
  <<
    \relative { c'1~ 2. e8 f }
    \\
    \relative {
      e''8 e e e
      e e e e
      f2 g
    }
  >>
}

[image of music]

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
  <<
    \relative { c'1~ 2. e8 f }
    \\
    \relative {
      \override Beam.positions = #'(-1 . -1)
      e''8 e e e
      e e e e
      f2 g
    }
  >>
  <<
    \relative { c'1~ 2. e8 f }
    \\
    \relative {
      e''8 e e e
      e e e e
      f2 g
      \revert Beam.positions
    }
  >>
}

[image of music]

Note that the override continues to apply in the second voice of the second measure of eighth notes, but not to any of the beams in the first voice, even those in the later second measure. As soon as the override should no longer apply it should be reverted, as shown.


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 {
  \key aes \major
  <<
    { c''2 aes4. bes8 }
    \\
    { <ees, c>2 des }
    \\
    \\
    { aes'2 f4 fes }
  >> |
  <c ees aes c>1 |
}

[image of music]

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, so we use \shiftOff.

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 {
  \key aes \major
  <<
    { c''2 aes4. bes8 }
    \\
    { <ees, c>2 \once \override NoteColumn.force-hshift = 0.5 des }
    \\
    \\
    { \once \shiftOff aes'2 \once \shiftOff f4 fes }
  >> |
  <c ees aes c>1 |
}

[image of music]


LilyPond — Learning Manual v2.24.4 (stable-branch).