Jump to content

Removing the key signature at the end of a line

From LilyPond wiki
Revision as of 18:52, 16 November 2025 by Jean Abou Samra (talk | contribs) (Replace version="2.24.0" with version="2.24" now that the LilyWiki extension supports auto-selecting the latest release in a stable series)

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"

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