調号の取り消し表示を新たな調号から離す

デフォルトでは、調号が変更される際のナチュラルによる取り消し表示は、新たな調号のすぐ隣に配置されます。この挙動は、BreakAlignment Grob の break-align-orders プロパティをオーバライドすることで変更できます。

break-align-orders は長さ 3 のベクトルで、それぞれが改行可能なアイテムを要素とした quote リストを取ります。この例では 2 つ目のリストのみを変更しており、key-cancellationstaff-bar の前に移動しています。2 番目の要素はシステムの途中における配置に影響し、行頭あるいは行末には影響しません。

#(define (insert-before where what lst)
   (cond
    ((null? lst)           ; If the list is empty,
     (list what))          ; return a single-element list.
    ((eq? where (car lst)) ; If we find symbol `where`,
     (cons what lst))      ; insert `what` before curr. position.
    (else                  ; Otherwise keep building the list by
     (cons (car lst)       ; adding the current element and
                           ; recursing with the next element.
           (insert-before where what (cdr lst))))))

cancellationFirst =
\override Score.BreakAlignment.break-align-orders =
#(grob-transformer
  'break-align-orders
  (lambda (grob orig)
    (let* ((middle (vector-ref orig 1))
           (middle (delq 'key-cancellation middle))
           (middle (insert-before
                    'staff-bar 'key-cancellation middle)))
      (vector
       ;; end of line
       (vector-ref orig 0)
       ;; middle of line
       middle
       ;; beginning of line
       (vector-ref orig 2)))))

music = { \key es \major d'1 \bar "||"
          \key a \major d'1 }

{ <>^\markup "default"
  \music }

{ <>^\markup "cancellation first"
  \cancellationFirst
  \music }

\paper { tagline = ##f }

[image of music]


LilyPond snippets v2.25.15 (開発版).