4

In LilyPond (ver. 2.18.2), I'm notating some Ligeti (as a challenge, mostly). When writing out a snippet of his Étude En Suspens, mm. 18-21, there's a passage with different keys between the bottom and top staff (bottom in C major at bar 18, top in D♭ major). Three measures later, they swap keys (bottom in D♭, top in C).

Question: How can I get LilyPond to keep both staves' key signatures aligned?

Screenshot of PDF created by LilyPond: Étude en Suspens, MM.18-21

LilyPond Code

\version "2.18.2"
\include "english.ly"
\include "articulate.ly"

\pointAndClickOff
#(set-global-staff-size 20)

\header
{
  title = "Étude En Suspens"
  composer = "György Ligeti (1923-2006)"
  tagline = ##f
}

\score
{
  <<
    \new PianoStaff
    {
      <<
        \new Staff = "upper-staff"
        {
          \override Staff.TimeSignature #'stencil = ##f
          \set Score.tempoHideNote = ##t
          \relative c''
          {
            \clef treble
            \time 6/4
            \key df \major
            f4^>_\pp( ef df bf2) 
            <<
              {
                s4 |
                s4*4 f'4^>(\< ef | \stemDown
                <df af'>4 <f gf> <af, bf'>4\p <bf af'>2.)_\pp \stemNeutral
              }
              \\
              {
                <f' gf>4^>( |
                ef4 df bf af gf2) |
                s4*6
              }
            >>

            \key c \major
            <b' c>4^>( a g e2) <g d'>4^>
          }
        }

        \new Staff = "lower-staff"
        {
          \override Staff.TimeSignature #'stencil = ##f
          \relative c''
          {
            \clef treble
            \time 6/4
            \key c \major
            e4.^>_\pp( d4. c4. b4. |
            a2.)
              \shape #'( (0 . -2) (0 . 1) (0 . 0) (0 . -1)) Slur
              <b c>4.(\< <g a'>4.\p |
            d'2.\> <a e'>2.)\pp |

            \key df \major
            <gf af>4.->( gf4. f4. ef4.)
          }
        }
      >>
    }
  >>

  \layout
  {
    \context
    {
      \Score
    }
  }
}

1 Answer 1

5

The naturals are printed by a KeyCancellation object, while the flats are a KeySignature. When LilyPond wants to align prefatory matter (like time signatures, clefs, key signatures, etc.), it looks up the break-align-symbol property on each grob (graphical object), and groups grobs according to values of this property. The default is key-cancellation for KeyCancellation and key-signature for KeySignature. By setting the break-align-symbol of KeyCancellation to be the same as that for KeySignature, you can achieve your desired alignment.

\override Staff.KeyCancellation.break-align-symbol = #'key-signature

In the code below, I have also made some simplifications:

  • The modern way to spell \include "english.ly" is \language english;
  • #(set-global-staff-size 20) is useless, since that is the default;
  • \override Something.stencil = ##f can be shortened as \omit Something.
\version "2.22.2"

\language english

\include "articulate.ly"
\pointAndClickOff

\header
{
  title = "Étude En Suspens"
  composer = "György Ligeti (1923-2006)"
  tagline = ##f
}

\new PianoStaff <<
  \new Staff = "upper-staff"
  {
    \omit Staff.TimeSignature
    \set Score.tempoHideNote = ##t
    \relative c'' {
      \clef treble
      \time 6/4
      \once \override Staff.KeyCancellation.break-align-symbol = #'key-signature
      \key df \major
      f4^>_\pp( ef df bf2) 
      <<
        {
          s4 |
          s4*4 f'4^>(\< ef | \stemDown
          <df af'>4 <f gf> <af, bf'>4\p <bf af'>2.)_\pp \stemNeutral
        }
        \\
        {
          <f' gf>4^>( |
          ef4 df bf af gf2) |
          s4*6
        }
      >>

      \key c \major
      <b' c>4^>( a g e2) <g d'>4^>
    }
  }

  \new Staff = "lower-staff" {
    \omit Staff.TimeSignature
    \relative c''
    {
      \clef treble
      \time 6/4
      \key c \major
      e4.^>_\pp( d4. c4. b4. |
      a2.)
        \shape #'( (0 . -2) (0 . 1) (0 . 0) (0 . -1)) Slur
        <b c>4.(\< <g a'>4.\p |
      d'2.\> <a e'>2.)\pp |

      \key df \major
      <gf af>4.->( gf4. f4. ef4.)
    }
  }
>>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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