[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: set page number

From: Hwaen Ch'uqi
Subject: Re: set page number
Date: Sun, 7 Feb 2021 06:07:22 -0500

Greetings David,

Not knowing what you halve already, it's a bit tricky to advise.
However, here is the code that I use, given a long time ago on this
list. It may be more than you need, because it also includes
provisions for correct numbering in the Table of Contents. This first
part goes above the \book block:

%%% roman numeral page numbers
#(define begin-arabic 11)

%% The following is an adaptation of a function found in
`define-markup-commands.scm' which is used to create tables of
contents. An offset to the Arabic numerals has been incorporated so
that the first page of the music is 1.
#(define-markup-command (page-ref layout props label gauge default)
  (symbol? markup? markup?)
  #:category other
@cindex referencing page numbers in text

Reference to a page number.  @var{label} is the label set on the referenced
page (using the @code{\\label} command), @var{gauge} a markup used to estimate
the maximum width of the page number, and @var{default} the value to display
when @var{label} is not found."
  (let* ((gauge-stencil (interpret-markup layout props gauge))
         (x-ext (ly:stencil-extent gauge-stencil X))
         (y-ext (ly:stencil-extent gauge-stencil Y)))
       ,(delay (ly:stencil-expr
                (let* ((table (ly:output-def-lookup layout 'label-page-table))
                       (page-number (if (list? table)
                                        (assoc-get label table)
                         (if page-number
                             (if (< page-number begin-arabic)
                                 (format #f "~(~@r~)" page-number) ;
Roman numerals
                                 ; Arabic numerals, but offset to begin on 1
                                 (format #f "~a" (- (1+ page-number)
                       (page-stencil (interpret-markup layout props
                       (gap (- (interval-length x-ext)
                               (interval-length (ly:stencil-extent
page-stencil X)))))
                  (interpret-markup layout props
                                    (markup #:concat (#:hspace gap

#(define-markup-command (roman-numeral-page-number layout props) ()
  (let ((page-number (chain-assoc-get 'page:page-number props -1)))
    (interpret-markup layout props
      (if (> page-number 0) ; only positive integers can be `romanized'
          (format #f "~(~@r~)" page-number)
          (chain-assoc-get 'page:page-number-string props -1)))))

#(define-markup-command (offset-page-number layout props offset) (integer?)
  (let ((page-number (chain-assoc-get 'page:page-number props -1)))
    (interpret-markup layout props
      (format #f "~a" (- page-number offset)))))

#(define (part-not-first-page layout props arg)
  (if (= (chain-assoc-get 'page:page-number props -1)
         (ly:output-def-lookup layout 'first-page-number))
      (interpret-markup layout props arg)))

You can change the begin-arabic number to whatever you need, the
number being the first Roman page that should have the Arabic number
1. Then, in the bookparts containing Arabic numbers, I include this in
the \paper block:

      oddHeaderMarkup = \markup {
        \fill-line {
          " "
          \on-the-fly #create-page-number-stencil \offset-page-number #(1-
      evenHeaderMarkup = \markup {
        \fill-line {
          \on-the-fly #create-page-number-stencil \offset-page-number #(1-
          " "


Hwaen Ch'uqi

On 2/7/21, <> wrote:
> I have a series of scores in a small book.  I want to have the first couple
> of pages numbered in Roman numerals and then switch to Arabic.  I have
> accomplished that.  The problem I face now is that I want the first Arabic
> numbered page to be page 1.  There is '\set currentBarNumber' but there does
> not seem to be a corresponding '\set currentPageNumber' or equivalent.
> There must be a way to do this.
> Thanks for any help.
> David

reply via email to

[Prev in Thread] Current Thread [Next in Thread]