Jump to content

Key signatures for small staves

From LilyPond wiki

Traditionally, the spacing of key signatures in smaller staves is larger in comparison to full-size staves.

Here is a function that extends \magnifyStaff to automatically calculate the right key signature spacing according to the staff size.

\version "2.24"

scaleStaff =
#(define-music-function (scaleFac) (number?)
  #{
    \magnifyStaff #scaleFac
    \override KeySignature.padding = #(* 2/3 (- 1 scaleFac))
  #})

keyTest = { \key cis\major s4*4 \bar "" }

\markup\italic "Default output:"
<<
  \new Staff \with { \magnifyStaff #5/7 } \keyTest
  \new Staff \keyTest
>>

\markup\italic "Traditional output:"
<<
  \new Staff \with { \scaleStaff #5/7 } \keyTest
  \new Staff \keyTest
>>