8

Is it possible to tell LilyPond to automatically add extra space for piano pedal symbols, so they don't overlap? If not, how to add the space manually?

Here is what I am trying to achieve: Three measures from the source score

This is what I get:

Same three measures as engraved by LilyPond

You can see that the pedal symbols overlap in the second measure.

This is the code:

\version "2.22.1"
\language "italiano"

common = {
    \key sol \minor
    \time 4/4
    \tempo "Largro [Широко]"
}

right = \relative do'' {
    \common
    <fa, sib re>2 <sol sib sol'>2 (
    <fa re' fa>4 <sol do mib>2.)
    <fad la re>2~ 8 r8 r4
}

left = \relative do' {
    \common
    <sib, sib'>2 <mib, mib'>2 (
    <sib sib'>4 <do do'>2.)
    <<
        {
            \tempo \markup {\smaller \normal-text "(poco rit.)"}
            re'4 r s2
        } \\
        {
            re,8 (la' re la' re2)
        }
    >>
}

pedal = {
    s2 \sustainOn s2 \sustainOff \sustainOn |
    s4 \sustainOff \sustainOn s2. \sustainOff \sustainOn |
    s8 \sustainOff
}

\score {
    \new PianoStaff <<
        \new Staff = "right" \right
        \new Staff = "left" { \clef bass \left }
        \new Dynamics \pedal
    >>
    \layout {
        \context {
            \Voice
            \consists "Melody_engraver"
            \override Stem #'neutral-direction = #'()
        }
    }
}
5
  • Would you consider it satisfactory to move the notes themselves to avoid the overlap?
    – Aaron
    Jul 25, 2021 at 20:36
  • Sure, a workaround will do. Still would be curious to know if LilyPond can do it automatically. How to move notes?
    – facetus
    Jul 25, 2021 at 20:39
  • FYI: I've added an addition solution to my answer that I think will work even better for what you're trying to do — the X-offset property.
    – Aaron
    Jul 25, 2021 at 23:13
  • Aside: do you mean "Largo" rather than "Largro" in the tempo marking? Jul 26, 2021 at 13:21
  • This is a typo, obviously.
    – facetus
    Jul 26, 2021 at 23:48

1 Answer 1

7

Solution #1: X-offset property

Modify the pedal block with \override SustainPedal.X-offset = 0.5.

For example:

pedal = {
    s2 \sustainOn s2 \sustainOff \sustainOn |
    s4 \sustainOff \sustainOn
    \override SustainPedal.X-offset = 0 { s2. \sustainOff \sustainOn } |
    s8 \sustainOff
}

yields

Solution 1 resulting image

Solution #2: extra-spacing-width property

Modify the pedal block with \override SustainPedal.extra-spacing-width = #'(left-space . right-space).

For example:

pedal = {
    s2 \sustainOn s2 \sustainOff \sustainOn |
    \override SustainPedal.extra-spacing-width = #'(0 . 0) { s4 \sustainOff \sustainOn } s2. \sustainOff \sustainOn |
    s8 \sustainOff

yields

Solution 2 resulting image

References

For more information, see the LilyPond manual. Specifically:

The key detail comes from the "Grob Sizing" section.

By default, outside-staff objects are given a width of zero so that they may overlap in the horizontal direction.

2
  • 1
    Thank you! I think I can do one small correction to your code. After some experimenting, I realized that the left side number in extra-spacing-width is supposed to be negative. Setting it to (5 . 5) is equivalent to (0 . 0).
    – facetus
    Jul 25, 2021 at 23:56
  • 1
    Another interesting thing is that extra-spacing-width = #'(0 . N) and \override SustainPedal.extra-spacing-width = #'(-N . 0) produce the same result.
    – facetus
    Jul 26, 2021 at 0:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.