4

When I start this piece with a grace note, it messes up formatting: bad formatting

Code:

\version "2.18.2"

\header {
    title = "Sonata in D Major"
    composer = "Joseph Haydn"
    opus = "Hob. XVI/37"
}

\language "english"

upper = \relative c'' {
    \clef treble
    \key d \major
    \time 4/4

    r4 r8 <cs a'> <d gs>( <cs a'>) <d gs>( <cs a'>) %m1
}

lower = \relative c {
    \clef treble
    \key d \major
    \time 4/4

    \grace gs''8( a-!) a,-! a-! a-! b(\trill a) b(\trill a)
}

\score {
    \new PianoStaff <<
        \set PianoStaff.instrumentName = #"Piano  "
        \new Staff = "upper" \upper
        \new Staff = "lower" \lower
    >>
    \layout { }
    \midi { }
}

If I remove the \grace indication, it works (but of course, without the grace note):

good format

How can I use this grace note while keeping the correct formatting? Is this a bug with Lilypond?

MCMastery
  • 3,099
  • 2
  • 20
  • 43

1 Answers1

8

This is a knnown problem but there is a workaround: just add a spacer grace note ( \grace s8 ) at the upper staff, before the r4 rest.

\grace s8 r4 r8 <cs a'> % etc

lilypond output sample

A fix for the problem is proposed to be investigated this summer during Google GSoC, see http://lilypond.org/google-summer-of-code.html

Paco
  • 416
  • 2
  • 2
  • This works, but unfortunately this will remove the staff name ("Piano"). If this is the only workaround I'll use this, but it would be nice if the Piano text could be displayed – MCMastery May 05 '16 at 20:02
  • 1
    Well, that effect already arose in the original example, and therefore it is not triggered by the workaround. Rather, it is another side effect of the bug. A solution is to establish the PianoStaff name in a \with clause, \new PianoStaff \with { instrumentName = #"Piano " } << %etc instead of the \set, which unfortunately is in sync with the grace and maybe that's why it causes problems. – Paco May 05 '16 at 22:50