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

[image of music]

% 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

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

left-padding and 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 following example shows one situation where it is needed. Suppose we wish to show a chord containing both a B-natural and a B-flat. To avoid ambiguity we would like to precede the notes with both a natural and a flat sign. Here are a few attempts to do this:

<b bes>
<b! bes>
<b? bes>

[image of music]

None work, with the second two showing bad collisions between the two signs.

One way of achieving this is to override the accidental stencil with a markup containing the natural and flat symbols in the order we would like, like this:

naturalplusflat = \markup { \natural \flat }
\relative c'' {
  \once \override Accidental
    #'stencil = #ly:text-interface::print
  \once \override Accidental #'text = #naturalplusflat
  \once \override Score.AccidentalPlacement #'right-padding = #1.5
  <b bes>
}

[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 natural sign followed by a flat sign. These are 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

[image of music]

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 >

[image of music]

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:

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

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

[image of music]

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
f-5
\once \override Fingering
    #'extra-offset = #'(-0.3 . -1.8)
f-5

[image of music]

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\)

[image of music]

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\)

[image of music]

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\)

[image of music]

Here’s a further example taken from the opening of the left-hand staff of Chopin’s Prelude Op 28 No. 2. We see that the beam collides with the upper notes:

{
\clef "bass"
<< {b,8 ais, b, g,} \\ {e, g e, g} >>
<< {b,8 ais, b, g,} \\ {e, g e, g} >>
}

[image of music]

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

{
  \clef "bass"
  <<
    \override Beam #'positions = #'(3 . 3)
    {b,8 ais, b, g,}
  \\
    {e, g e, g}
  >>
  << {b,8 ais, b, g,} \\ {e, g e, g} >>
}

[image of music]

Note that the override continues to apply in the first voice of the second block of quavers, 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
      des2
    }
  >> |
  <c ees aes c>1 |
}

[image of music]

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 |
}

[image of music]


Other languages: français, español, deutsch.

Learning Manual