On Fri, 2025-08-29 at 20:33 +0000, Magnus Svenson wrote:
> 
> 
> %%
> \version "2.24.4"
> \language "english"
> 
> 
> 
> 
> \layout { 
> 
> \override Score.BreakAlignment.break-align-orders =
> #(make-vector 3 '(left-edge
> cue-end-clef
> ambitus
> breathing-sign
> clef
> cue-clef
> key-cancellation
> key-signature
> staff-bar
> time-signature
> custos)) 
> 
> \override Score.KeySignature.extra-spacing-width = #'(-2.0 . 0.0)
> \override Score.KeyCancellation.extra-spacing-width = #'(-2.0 . 0.0)
> }
> 
> 
> 
> mymusic = \fixed c'' {
> \key g \major
> c4 c c c
> 
> \key f \major 
> \bar "||"
> c c c c
> 
> \key c \major
> c4 c c c
> }
> 
> 
> \score {
> \new Staff \mymusic
> \layout { }
> }
> 
> %%
> 
> https://lilypond.org/doc/v2.24/Documentation/internals/breakalignment
> 
> The spacing looks tight without adjustments, change to your
> preferences.
> 
Thank you very much for this, this solution applies to all key changes
in the score, but I found it was easy to insert the code before
specific key changes and then use \revert to go back to the normal
behavior which covers that case too.
However, there is a further case where, for example, there are first
and second time bars, with the first time bar is going back to the
beginning in a different key, while the second time bar goes on in the
same key. This really requires drawing a keychange which is purely
graphical, as putting a (cautionary) keychange at the end of the first
time bar fools LilyPond into thinking the second time bar is in that
key. 
This is illustrated by this example:

8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><
\version "2.25.18"

\score {
       { 
         \key d \major
         \repeat volta 2 {
                          g' c' c' c'
                          c' c' c' c'
                          \key e \major
                          gis' c' c' c'
        \alternative {
                      {c' c' c' c' 
                       \override Score.BreakAlignment.break-align-orders =
                                  #(make-vector 3 '(left-edge
                                  cue-end-clef
                                  ambitus
                                  breathing-sign
                                  clef
                                  cue-clef
                                  key-cancellation
                                  key-signature
                                  staff-bar
                                  time-signature
                                  custos)) 
                        
                        \override Score.KeySignature.extra-spacing-width = 
#'(-2.0 . 0.0)
                        \override Score.KeyCancellation.extra-spacing-width = 
#'(-2.0 . 0.0)
                      \key d \major    }
                      {gis' c' c' c'
                         \revert Score.BreakAlignment.break-align-orders 
                        \revert Score.KeySignature.extra-spacing-width 
                        \revert Score.KeyCancellation.extra-spacing-width 
                       \key f \major }
                     }
        }
       bes' c' c' c'
       c' c' c' c'
      
      }
}
8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><

Is it possible to create an keychange engraver that doesn't actually
change the key, but still uses the same stencil?

Richard
(The late response is due to some problem in the delivery of emails
from the list - they are coming in erratically up to a day or so late)


Reply via email to