Wow, thank you SO MUCH! Works perfectly!!!

Hwaen Ch'uqi


On 2/18/24, Thomas Morley <[email protected]> wrote:
> Am Do., 15. Feb. 2024 um 19:16 Uhr schrieb Hwaen Ch'uqi
> <[email protected]>:
>>
>> Greetings,
>>
>> Until upgrading to 2.24, I had been using certain Scheme code and
>> \paper block layouts in order to output books consisting of prefatory
>> material with Roman numeral page numbers and the music itself with
>> Arabic page numbers. When I upgraded one such file to 2.24.3 using
>> convert-ly, the result was puzzling. The actual page numbering is
>> correct - ten pages of either invisible or Roman numerals followed by
>> Arabic numerals starting on page 1. However, the Table of Contents
>> shows Arabic numerals from the beginning, so that the first page of
>> actual music is 11. I am not sure what to present as an MWE; I am
>> guessing that the Scheme code and \paper blocks should suffice. The
>> original was laid out as follows:
>>
>> %%% 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)))
>>     (ly:make-stencil
>>      `(delay-stencil-evaluation
>>        ,(delay (ly:stencil-expr
>>                 (let* ((table (ly:output-def-lookup layout
>> 'label-page-table))
>>                        (page-number (if (list? table)
>>                                         (assoc-get label table)
>>                                         #f))
>>                        (page-markup
>>                          (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)
>> begin-arabic)))
>>                              default))
>>                        (page-stencil (interpret-markup layout props
>> page-markup))
>>                        (gap (- (interval-length x-ext)
>>                                (interval-length (ly:stencil-extent
>> page-stencil X)))))
>>                   (interpret-markup layout props
>>                                     (markup #:concat (#:hspace gap
>> page-markup)))))))
>>      x-ext
>>      y-ext)))
>>
>> #(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))
>>       empty-stencil
>>       (interpret-markup layout props arg)))
>>
>> \book {
>>
>> \bookpart {
>>
>>     \paper {
>>       oddHeaderMarkup = \markup \fill-line {
>>         " "
>>       }
>>       evenHeaderMarkup = \markup \fill-line {
>>         " "
>>       }
>>     }
>>
>> Title, copyright, and dedication pages.
>>
>>   }
>>
>> \bookpart {
>>
>>     \paper {
>>       oddHeaderMarkup = \markup \fill-line {
>>         " "
>>       }
>>       evenHeaderMarkup = \markup \fill-line {
>>         " "
>>       }
>>       oddFooterMarkup = \markup \fill-line {
>>         " "
>>         \on-the-fly #print-page-number-check-first
>> \roman-numeral-page-number
>>         " "
>>       }
>>       evenFooterMarkup = \oddFooterMarkup
>>       tocTitleMarkup = \markup \column {
>>         \vspace #3
>>         \fill-line \abs-fontsize #16 \bold {
>>           "TABLE OF CONTENTS"
>>         }
>>         \vspace #2
>>       }
>>       tocItemMarkup = \markup \column {
>>         \fill-with-pattern #1 #RIGHT . \fromproperty #'toc:text
>> \fromproperty
>> #'toc:page
>>         \vspace #1
>>       }
>>     }
>>
>>     \markuplist \table-of-contents
>>
>> Preface and Performance Notes.
>>
>>   }
>>
>> \bookpart {
>>
>>     \paper {
>>       oddHeaderMarkup = \markup {
>>         \fill-line {
>>           " "
>>           \on-the-fly #create-page-number-stencil \offset-page-number
>> #(1-
>> begin-arabic)
>>         }
>>       }
>>       evenHeaderMarkup = \markup {
>>         \fill-line {
>>           \on-the-fly #create-page-number-stencil \offset-page-number
>> #(1-
>> begin-arabic)
>>           " "
>>         }
>>       }
>>     }
>>
>> Music.
>>
>>   }
>>
>> }
>>
>> The first of the \paper blocks remained unchanged in the new version.
>> The second and thrid were replaced by the following:
>>
>>     \paper {
>>       oddHeaderMarkup = \markup \fill-line {
>>         " "
>>       }
>>       evenHeaderMarkup = \markup \fill-line {
>>         " "
>>       }
>>       oddFooterMarkup = \markup \fill-line {
>>         " "
>>         \if \should-print-page-number \roman-numeral-page-number
>>         " "
>>       }
>>       evenFooterMarkup = \oddFooterMarkup
>>       tocTitleMarkup = \markup \column {
>>         \vspace #3
>>         \fill-line \abs-fontsize #16 \bold {
>>           "TABLE OF CONTENTS"
>>         }
>>         \vspace #2
>>       }
>>       tocItemMarkup = \markup \column {
>>         \fill-with-pattern #1 #RIGHT . \fromproperty #'toc:text
>> \fromproperty
>> #'toc:page
>>         \vspace #1
>>       }
>>     }
>>
>>     \paper {
>>       oddHeaderMarkup = \markup {
>>         \fill-line {
>>           " "
>>           \if \should-print-page-numbers-global \offset-page-number #(1-
>> begin-arabic)
>>         }
>>       }
>>       evenHeaderMarkup = \markup {
>>         \fill-line {
>>           \if \should-print-page-numbers-global \offset-page-number #(1-
>> begin-arabic)
>>           " "
>>         }
>>       }
>>     }
>>
>> At the end of the day, I am not familiar enough with Scheme to know
>> how to solve this issue. I would be grateful for any assistance.
>>
>> Hwaen Ch'uqi
>>
>
> Hi,
>
> would have been nice if bookpart-level-page-numbering and
> page-number-type could be used to make it work out of the box.
> See:
> https://gitlab.com/lilypond/lilypond/-/issues/6696
> https://gitlab.com/lilypond/lilypond/-/issues/6697
>
> For now, how about attached?
>
> HTH,
>   Harm
>

Reply via email to