On 30/11/2025 03:38, David Wright wrote:
If you print double-sided, take care that your score generates an
even number of physical pages, else your organist's first page will
have the choirmaster's last page printed on the back, and alternate
members of the choir will be turning their pages at different points
in the score. But there is a size advantage in writing one file (if
size matters), presumably through compressing duplicated material.
I do not know whether the amount of data that flows from computer
to printer is reduced, though.

This issue has bothered me previously, so I devised a page breaking method that forces bookparts to start on a recto page. First the pages are broken using one of LilyPond's built-in algorithms, which is passed as an argument. If any bookpart (except the last one) ends on an odd page, a blank page is constructed and appended to the bookpart.

I also realised the method to build the book could be simplified.

\version "2.24.4"

#(use-modules (srfi srfi-1))
#(use-modules (lily page))

#(define (newpageprops new-page lines config is-last-bookpart)
  (page-set-property! new-page 'lines lines)
  (page-set-property! new-page 'configuration config)
  (page-set-property! new-page 'is-last-bookpart is-last-bookpart))

#(define (bookpart-recto pagebreakalgo)
(lambda (paper-book)
   (let ((default-pages (pagebreakalgo paper-book)))
     (append-map
       (lambda (this-page)
         (let* ((page-number (page-property this-page 'page-number))
                (config (page-property this-page 'configuration))
                (lines (page-property this-page 'lines))
                (is-last-page (page-property this-page 'is-bookpart-last-page))                 (is-last-bookpart (page-property this-page 'is-last-bookpart)))
           (if (and is-last-page (odd? page-number) (not is-last-bookpart))
             (let* ((blank-page (make-page paper-book (1+ page-number) #t))
                    (new-page (make-page paper-book page-number #f)))
               (page-set-property! blank-page 'head-stencil empty-stencil)
               (page-set-property! blank-page 'foot-stencil empty-stencil)
               (newpageprops new-page lines config is-last-bookpart)
               (list this-page blank-page))
             (let* ((new-page (make-page paper-book page-number is-last-page)))
               (newpageprops new-page lines config is-last-bookpart)
               (list this-page)))))
       default-pages))))

NN = 2 % how many numbered copies

myTitlePage = \markup \fill-line \huge { "This Is My Title Page" }

myScore = { c' \pageBreak d' }

myBookpart = #(define-scheme-function (n) ((lambda (x) (or (integer? x) (string? x))))
#{
  \bookpart {
    \markup \fill-line { #(format #f "Copy ~a" n) }
    \myTitlePage
    \pageBreak
    \myScore
  }
#})

\paper {
  page-breaking = #(bookpart-recto ly:optimal-breaking)
  bookpart-level-page-numbering = ##t
  oddFooterMarkup = \markup \fill-line { \if \on-last-page-of-part { \fromproperty #'header:tagline } }
}

\book {
  #(for-each
     (lambda (i) (ly:book-add-bookpart! $current-book (myBookpart i)))
     (append '("for Choirmaster" "for Organist") (iota NN 1)))
}


--
Timothy Lanfear, Bristol, UK.

Reply via email to