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.

On Sun, Oct 13, 2024 at 2:06 PM Cameron Hall <camerongh...@cox.net> wrote:

> This may seem very nitpicky, but how can I control the alignment of the
> text in a page-ref? I'm using "000" as the placeholder, since I want
> this to work with up to 3 digits of page numbers. Lilypond seems to
> compute the width of the "000" then *right* align the text inside of
> that space, so if the total page count is less than 3 digits, there is
> a noticeable gap between the "of" and the number. The box in this
> example is purely for visualization purposes and can be removed. I also
> tried putting the page-ref inside of a \left-align command, but it
> didn't have any effect.
>
> %%%
> \version "2.24.4"
> \paper {
>   oddFooterMarkup = \markup {
>     \line {
>       "Page"
>       \fromproperty #'page:page-number-string
>       "of"
>       \box { \page-ref #'end "000" "?" }
>     }
>   }
>   evenFooterMarkup = \oddFooterMarkup
> }
>
> {
>   \repeat unfold 6000 { c'4 }
>   \label #'end
> }
> %%%
>
>

Reply via email to