\version "2.24.0"
\language "deutsch"
%% based on
https://www.mail-archive.com/lilypond-user@gnu.org/msg119983.html
center =
#(define-music-function (text x-off) (markup? number?)
#{
\once \override Score.GridLine.stencil =
#(lambda (grob)
(let* ((stil (ly:grid-line-interface::print grob))
(stil-y-ext (ly:stencil-extent stil Y))
(thick (ly:grob-property grob 'thickness 0.1))
(center ( / (+ (car stil-y-ext) (cdr stil-y-ext))
2))
(note
(interpret-markup
(ly:grob-layout grob)
(ly:grob-alist-chain grob
(ly:output-def-lookup (ly:grob-layout grob)
'text-font-defaults))
text))
(note-y-ext (ly:stencil-extent note Y))
(height (interval-length (ly:stencil-extent note
Y)))
(y-off (- (- center (car note-y-ext)) ( / height
2))))
(ly:stencil-translate note (cons x-off y-off))))
#})
sig = \markup { \teeny \line { \note {2} #1 \note {4} #-1 } }
\score {
\new PianoStaff <<
\new Staff <<
\key d \major
\new Voice { \once \override Staff.TimeSignature. stencil
= ##f \voiceOne d'4 \bar "|" }
\new Voice { \voiceTwo \center \sig #-6.25 a4 }
>>
\new Staff <<
\clef bass \key d \major
\new Voice { \once \override Staff.TimeSignature. stencil
= ##f \voiceOne fis4 }
\new Voice { \voiceTwo d4 }
>>
>>
}
\layout {
\context {
\Score
\consists "Grid_line_span_engraver"
\override GridLine.stencil = ##f
}
\context {
\Staff
\consists "Grid_point_engraver"
%% adjust the value if needed
gridInterval = #(ly:make-moment 1/64)
}
}
HTH, Juergen.