4

Is it possible? How can I set the font size for the page numbers?

1 Answer 1

5

The page number is printed by the paper variables oddHeaderMarkup and evenHeaderMarkup. If you look into ly/titling-init.ly you will find the default values

oddHeaderMarkup = \markup
\fill-line {
  ""
  \unless \on-first-page-of-part \fromproperty #'header:instrument
  \if \should-print-page-number \fromproperty #'page:page-number-string
}

%% evenHeaderMarkup would inherit the value of
%% oddHeaderMarkup if it were not defined here
evenHeaderMarkup = \markup
\fill-line {
  \if \should-print-page-number \fromproperty #'page:page-number-string
  \unless \on-first-page-of-part \fromproperty #'header:instrument
  ""
}

As you see there is no hook to format the page number. So you’ll need to adjust this header as you deem fit:

\paper {
  oddHeaderMarkup = \markup
  \fill-line {
    ""
    \unless \on-first-page-of-part \fromproperty #'header:instrument
    \if \should-print-page-number \larger \fromproperty #'page:page-number-string
  }

  evenHeaderMarkup = \markup
  \fill-line {
    \if \should-print-page-number \larger \fromproperty #'page:page-number-string
    \unless \on-first-page-of-part \fromproperty #'header:instrument
    ""
  }
}
4
  • I don't see where I can set the font size
    – Student
    Jul 24, 2023 at 14:50
  • \if \should-print-page-number \larger \fromproperty #'page:page-number-string the \larger increases fontsize by one magstep. Alternatively you can do \fontsize #number or \abs-fontsize #number.
    – Lazy
    Jul 24, 2023 at 15:00
  • So I added oddHeaderMarkup = \markup \fill-line { "" \unless \on-first-page-of-part \fromproperty #'header:instrument \if \should-print-page-number \abs-fontsize #10 \fromproperty #'page:page-number-string } evenHeaderMarkup = \markup \fill-line { \if \should-print-page-number \abs-fontsize #10 \fromproperty #'page:page-number-string \unless \on-first-page-of-part \fromproperty #'header:instrument "" } to the \paper part of my ly file, and the result is not what it should be. Should it be added to the titling-init.ly file?
    – Student
    Jul 24, 2023 at 15:11
  • 1
    @Student No. titling-init.ly is a Lilypond default file, editing it will mean you’ll need to maintain this change over future Lilypond versions. But what to you mean by "the result is not what it should be"? This should change the font size for odd page numbers to be slightly smaller (the default is 11).
    – Lazy
    Jul 24, 2023 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.