Hello Pondmates, I’ve just stumbled upon a music SE question regarding the formatting of page numbers. Currectly we do not have any hooks to change formatting of such things, rather the general approach to this is "you need to change the whole titling procedure, here is the default value".
But while it is good that Lilypond generally allows us to do what we want here I think this should not really be necessary if all we want to do is to modfiy the style of one element. One way to get around this that is consistent with how e.g. mark formatting is handles would be to allow specifying a formatting function within an output- def. This can be implemented in a really nice straightforward manner. We can simply have a markup command like this #(define-markup-command (format-with layout props procedure mup) (symbol? markup?) (let ((procedure (ly:output-def-lookup layout procedure))) (if (procedure? procedure) (interpret-markup layout props (procedure mup)) (interpret-markup layout props mup)))) which simply allows us to put a \format-with 'procName in front of some markup to optionally allow formatting using the output-def field 'procName. E.g. the Header markup can simply be changed to \paper { oddHeaderMarkup = \markup \fill-line { "" \unless \on-first-page-of-part \format-with #'formatInstrumentHeader \fromproperty #'header:instrument \if \should-print-page-number \format-with #'formatPageNumber \fromproperty #'page:page-number-string } evenHeaderMarkup = \markup \fill-line { \if \should-print-page-number \format-with #'formatPageNumber \fromproperty #'page:page-number-string \unless \on-first-page-of-part \format-with #'formatInstrumentHeader \fromproperty #'header:instrument "" } } and suddenly we can easily format specific elements: \header { instrument = "Test" } \paper { formatPageNumber = #(lambda (x) (markup #:override '(font-size . 10) #:circle x)) formatInstrumentHeader = #(lambda (x) (markup #:box x)) } \markup\null \pageBreak \markup\null In fact this can easily be done in a way such that different fields use the same formatting, but may be broken up to use different formatting: \paper { oddHeaderMarkup = \markup \fill-line { "" \unless \on-first-page-of-part \format-with #'formatOddInstrumentHeader \fromproperty #'header:instrument \if \should-print-page-number \format-with #'formatOddPageNumber \fromproperty #'page:page-number-string } evenHeaderMarkup = \markup \fill-line { \if \should-print-page-number \format-with #'formatEvenPageNumber \fromproperty #'page:page-number-string \unless \on-first-page-of-part \format-with #'formatEvenInstrumentHeader \fromproperty #'header:instrument "" } formatOddPageNumber = #(lambda (x) (markup #:format-with 'formatPageNumber x)) formatEvenPageNumber = #(lambda (x) (markup #:format-with 'formatPageNumber x)) formatOddInstrumentHeader = #(lambda (x) (markup #:format-with 'formatInstrumentHeader x)) formatEvenInstrumentHeader = #(lambda (x) (markup #:format-with 'formatInstrumentHeader x)) } This allows to set 'formatPageNumber or 'formatInstrumentHeader to generally change the formatting, or 'formatOdd/EvePageNumber and 'formatOdd/ EvenInstrumentHeader to change formatting only for Odd/Even pages. In my opinion it would not affect the complexity of Lilypond much to add such hooks to all common markup fields, and it would make tweaking specific fields much easier. Cheers, Valentin
signature.asc
Description: This is a digitally signed message part.