\version "2.13.54" #(ly:set-option 'debug-skylines) BoxMarkTextIIa = #(define-music-function (parser location MarkText AddText x-align) (string? string? number?) #{ \once \override Score.RehearsalMark #'self-alignment-X = #$x-align \mark \markup { \bold { \box $MarkText \normalsize $AddText }} #}) #(define-markup-command (center-at-markIIb layout props mark text) (string? string?) "x-align on the center of the rehaersal mark" (let* ( (txt (markup #:normal-text #:bold #:normalsize #:concat (" " text))) (txt-stencil (interpret-markup layout props txt)) (txt-x-ext (ly:stencil-extent txt-stencil X)) (txt-width (- (cdr txt-x-ext)(car txt-x-ext))) (mrk (markup #:normal-text #:box #:bold mark)) (mrk-stencil (interpret-markup layout props mrk)) (mrk-x-ext (ly:stencil-extent mrk-stencil X)) (mrk-width (- (cdr mrk-x-ext)(car mrk-x-ext))) (x-align (- (/ mrk-width (+ txt-width mrk-width)) 1 )) ) (interpret-markup layout props (markup #:halign x-align #:concat (mrk txt))) )) BoxMarkTextIIb = #(define-music-function (parser location MarkText AddText) (string? string?) #{ % Alternative using \halign within the markup % \halign only has effect if X-offset is set to #0 \once \override Score.RehearsalMark #'X-offset = #0 \mark \markup { \center-at-markIIb #$MarkText #$AddText } #}) \score { \relative c'' { \clef "G" \key c \major \time 4/4 % Option IIa, an override before the markup works as expected % I could calulate the value for x-align with a markup script but how do I get the resul % in the override? \BoxMarkTextIIa #"10" #"Theme from 007" #-0.83 c1 \bar "||" e( f) \BoxMarkTextIIa #"11" #"Theme from 007" #-0.83 g( e) \break % Option IIb, /halign inside the markup. % Makes it possible to calculate the value for x-align inside a markup script. % But, setting X-offset to "0" leads to misalignment on the clef. See mark 12. \BoxMarkTextIIb #"12" #"Theme from 007" c1 \bar "||" e( f) \BoxMarkTextIIb #"13" #"Theme from 007" g( e) } } \layout{ indent = 0 ragged-right = ##t \context { \Staff \remove "Time_signature_engraver" } } %%% end of example