\version "2.17.96" % #(ly:set-option 'debug-skylines) #(define (format-mark-default mark context) " Set the format for the RehearsalMark. From the manual: The file ‘scm/translation-functions.scm’ contains the definitions of format-mark-numbers " ; Uncomment one of these options ; (format-mark-alphabet mark context) ; (format-mark-box-alphabet mark context) ; (format-mark-circle-alphabet mark context) ; (format-mark-letters mark context) ; (format-mark-box-letters mark context) ; (format-mark-circle-letters mark context) ; (format-mark-numbers mark context) (format-mark-box-numbers mark context) ; (format-mark-circle-numbers mark context) ; (format-mark-barnumbers mark context) ; (format-mark-box-barnumbers mark context) ; (format-mark-circle-barnumbers mark context) ) #(define-markup-command (center-at-mark layout props mark text x-align) (markup? string? number?) " Markup command used in RehearsalMarkWithText Check the value of x-align and print the correct value when neccessary " (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-stencil (interpret-markup layout props mark)) (mrk-x-ext (ly:stencil-extent mrk-stencil X)) (mrk-width (- (cdr mrk-x-ext)(car mrk-x-ext))) (x-align-new (- (/ mrk-width (+ txt-width mrk-width)) 1 )) (x-dif (abs (- x-align-new x-align))) (x-dif-markup (markup #:small (format "Change x-align to: ~5,2F" x-align-new))) ) (interpret-markup layout props (if (< x-dif 0.02) (markup #:concat (mark txt)) ;else (markup #:with-color blue #:box (#:column (x-dif-markup #:with-color black #:concat (mark txt)))) ) ) )) RehearsalMarkWithText = #(define-music-function (parser location text x-align) (string? number?) " Calculate the value for x-align inside a markup script and hint the user for the correct value. This a a manual solution that (in my opinion) shouldn't be neccessary. The format for the RehearsalMark is defined in the procedure: format-mark-default text this is a string that is addded with a dividing space to the RehearsalMark x-align this defines the alignment: -1 is left and +1 is right. Use -1 for your first call and the correct value will be printed near the RehearsalMark. " #{ % Redefine the Rehearsal mark % \once does work but generates multiple warning. \set Score.markFormatter = #(lambda (mark context) (markup #:center-at-mark (format-mark-default mark context)text x-align)) \once \override Score.RehearsalMark.self-alignment-X = #x-align \mark \default % Revert to the original format: This doesn't work in here! % Thats why I defined \RehearsalMark which is used instead of \mark \default %\set Score.markFormatter = #format-mark-box-numbers %\unset Score.markFormatter #}) % Use this function instead of \mark \default RehearsalMark = { \set Score.markFormatter = #format-mark-default \mark \default } \score { \relative c'' { \clef "G" \key c \major \time 4/4 % Setting the startingpoint can be omitted as you would normaly start at #1 \set Score.rehearsalMark = #10 \RehearsalMarkWithText #"Theme from 007" #-1 % This means left aligned which is a good start c1 e( f) \bar "||" \RehearsalMarkWithText #"Theme from 007" #-0.83 % The calculated value for x-align is applied g( e) \break \RehearsalMark % Revert to \mark \default c1 e( f) \bar "||" \RehearsalMark g( e) } } \layout{ indent = 0 ragged-right = ##t \context { \Staff \remove "Time_signature_engraver" } } %%% end of example