Post by Michael GerdauHi list,
I'm trying to control the page numbering for bookparts in a score.
In particular I want each bookpart start with page #1 and omit it
on the first page. Therefor I'm adding a paper block inside bookpart
and set
first-page-number = #1
print-first-page-number = ##f
(see the attached example)
Unfortunately the second page is numbered 2 and visible, i.e. both
settings seem to have no effect.
What am I doing wrong here?
[I'm aware I could place each bookpart in a separate file and process
them individually]
Kind regards,
Michael
The possibility to set starting page-numbers for bookparts is
frequently requested, but not yet done.
As a workaround I recently did the coding below, though it's still
work in progress and currently I've not the time to go further on this
topic.
Maybe it's already enough for your needs, probably a starting point otherwise:
\version "2.19.48"
#(define part-first-pages '(0))
#(define (part-first-page? layout props)
(= (chain-assoc-get 'page:page-number props -1)
(ly:output-def-lookup layout 'first-page-number)))
#(define (reset-part-first-page layout props arg)
"Returns page-number-string, starting every bookpart with page-number 0.
Relying on the extern defined `part-first-pages'.
"
(set! props (prepend-alist-chain 'part-first-page '(0) props))
(let* ((real-page-number (chain-assoc-get 'page:page-number props -1))
(parts-page-number (- real-page-number (car part-first-pages))))
(if (part-first-page? layout props)
(set! part-first-pages (cons (1- real-page-number) part-first-pages)))
(set! props
(cons
(list
(cons 'page:page-number-string (number->string parts-page-number))
(cons 'page:page-number parts-page-number))
props))
(interpret-markup layout props arg)))
#(define ((print-part-first-page-as-one number-type) layout props arg)
(set! props
(cons
(list
(cons 'page:page-number-string
(let ((page-number
(chain-assoc-get 'page:page-number props -1)))
(cond ((eq? number-type 'roman-lower)
(fancy-format #f "~(~@r~)" page-number))
((eq? number-type 'roman-upper)
(fancy-format #f "~@r" page-number))
((eq? number-type 'arabic)
(number->string page-number))
(else (number->string page-number)))))
(cons 'page:page-number
(chain-assoc-get 'page:page-number props -1)))
props))
(interpret-markup layout props arg))
\paper {
%first-page-number = #-3
print-first-page-number = ##t
oddMarkup =
#(define-scheme-function (number-type)(symbol?)
#{
\markup
\column {
\fill-line {
" "
\on-the-fly #not-part-first-page \fromproperty #'header:instrument
\on-the-fly #print-page-number-check-first
%% use in this order:
\on-the-fly #reset-part-first-page
\on-the-fly #(print-part-first-page-as-one number-type)
\fromproperty #'page:page-number-string
}
\vspace #5
}
#})
evenMarkup =
#(define-scheme-function (number-type)(symbol?)
#{
\markup
\column {
\fill-line {
\on-the-fly #print-page-number-check-first
%% use in this order:
\on-the-fly #reset-part-first-page
\on-the-fly #(print-part-first-page-as-one number-type)
\fromproperty #'page:page-number-string
\on-the-fly #not-part-first-page \fromproperty #'header:instrument
" "
}
\vspace #5
}
#})
oddFooterMarkup = \markup {
\column {
\fill-line {
\concat {
"real book number: "
\on-the-fly #print-page-number-check-first
\fromproperty #'page:page-number-string
}
}
\fill-line {
%% Copyright header field only on first page in each boob.
\on-the-fly #part-first-page \fromproperty #'header:copyright
}
\fill-line {
%% Tagline header field only on last page in the book.
\on-the-fly #last-page \fromproperty #'header:tagline
}
}
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXAMPLES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#(set-default-paper-size "a7")
\book {
\bookpart {
\markup
\column {
\vspace #5
\fill-line {
\override #'(box-padding . 10)
\rounded-box "MY BOOK 2"
}
}
}
\bookpart {
\paper {
%page-number-type = #'roman-lower
oddHeaderMarkup = \oddMarkup #'roman-lower
evenHeaderMarkup = \evenMarkup #'roman-lower
%oddFooterMarkup = ##f
}
\markuplist \table-of-contents
}
\bookpart {
\paper {
oddHeaderMarkup = \oddMarkup #'arabic
evenHeaderMarkup = \evenMarkup #'arabic
}
\tocItem "one1"
\tocItem "one2"
\tocItem "one3"
\tocItem "one4"
\tocItem "one1"
\tocItem "one2"
\tocItem "one3"
\tocItem "one4"
\repeat unfold 2 { c''1 \pageBreak }
}
\bookpart {
\paper {
oddHeaderMarkup = \oddMarkup #'arabic
evenHeaderMarkup = \evenMarkup #'arabic
}
\tocItem "two1"
\tocItem "two2"
\tocItem "two3"
\tocItem "two4"
\tocItem "two1"
\tocItem "two2"
\tocItem "two3"
\tocItem "two4"
\repeat unfold 2 { d''1 \pageBreak }
}
\bookpart {
\paper {
oddHeaderMarkup = \oddMarkup #'arabic
evenHeaderMarkup = \evenMarkup #'arabic
}
\tocItem "three1"
\tocItem "three2"
\tocItem "three3"
\tocItem "three4"
\tocItem "three1"
\tocItem "three2"
\tocItem "three3"
\tocItem "three4"
{ e''1 \pageBreak }
\tocItem "four1"
\tocItem "four2"
\tocItem "four3"
\tocItem "four4"
\tocItem "four1"
\tocItem "four2"
\tocItem "four3"
\tocItem "four4"
{ f''1 \pageBreak }
}
}
HTH a bit,
Harm