Removing the key signature at the end of a line

Revision as of 22:36, 26 October 2025 by Jean Abou Samra (talk | contribs) (Import snippet from LSR)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

According to normal typesetting conventions, LilyPond typesets key changes at the end of the line, when the change appears at a line break. This example shows how to change this default to only print the new key signature at the beginning of the next line.

\version "2.24.0"

%% http://lsr.di.unimi.it/LSR/Item?id=124

\paper {
  ragged-right = ##t
  tagline = ##f
}

\score {
   \relative c' {
    \set Staff.explicitKeySignatureVisibility = #end-of-line-invisible
    c d e f | g a b c | \break
    \key d \major
    d cis b a | g fis e d |
  }
}