Thursday, May 22, 2008

Centering LilyPond page numbers

LilyPond page numbers print in lower left and right corners by default. Printing LilyPond page numbers somewhere other than in these default locations requires some additions to the \paper block.

Specify LilyPond page numbers explicitly with the \on-the-fly #print-page-number-check-first and \fromproperty #'page:page-number-string incantations.

\paper {
print-page-number = ##t
print-first-page-number = ##t
oddHeaderMarkup = \markup \fill-line { " " }
evenHeaderMarkup = \markup \fill-line { " " }
oddFooterMarkup = \markup { \fill-line {
\bold \fontsize #3 \on-the-fly #print-page-number-check-first
\fromproperty #'page:page-number-string } }
evenFooterMarkup = \markup { \fill-line {
\bold \fontsize #3 \on-the-fly #print-page-number-check-first
\fromproperty #'page:page-number-string } }
}

Centering occurs thanks to \fill-line.

No comments: