> As far as I'm aware, one of the shortcomings of Lilypond's handling
> of text is that it only does one pass to calculate the size of
> markups. If the size of the actual text can vary dynamically, it
> won't be reflected in the layout. This is an issue, for example, if
> the page header contains the centered movement title pulled from the
> table of contents (such as when movements may start mid-page so
> bookparts can't be used). If the titles differ in length, some of
> them will not be centered properly.
>
> Your example here strikes me as a case where it is probably possible
> to fix the alignment. You might have a look at
> define-markup-commands.scm in the Lilypond source to see how
> \page-ref is defined.
>
> But I mention the underlying limitations because if your example were
> modified slightly to have static text both before and after the
> \page-ref, instead of only on one side, as far as I know there would
> be no way to get Lilypond to size the dynamically populated text
> correctly.
>
> Personally, this is a major reason why I have migrated to a setup
> where I handle nearly all the text typesetting in LaTeX, including
> headers and footers. Lilypond is outstanding for music typesetting
> but it just isn't really a robust system for typesetting text. It's
> hard to get line spacing correct, dealing with advanced features of
> text fonts is fairly rudimentary, etc.
I had a look at the definition of page-ref in
define-markup-commands.scm and see that it's specifically adding a gap
to the markup to right-align the text.
(interpret-markup layout props
(make-line-markup
(list
(make-hspace-markup gap)
page-markup)))
If I copy the function, but remove the "(make-hspace-markup gap)", then
I get the left-aligned page number like I want.
Thanks,
Cameron