Discussion:
Problem controlling page numbers in bookparts
Michael Gerdau
2016-10-26 13:29:36 UTC
Permalink
Hi 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
--
Michael Gerdau email: ***@qata.de
GPG-keys available on request or at public keyserver
Thomas Morley
2016-10-26 21:54:25 UTC
Permalink
Post by Michael Gerdau
Hi 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
Kieren MacMillan
2016-10-26 23:21:26 UTC
Permalink
Hi all,
Post by Thomas Morley
Post by Michael Gerdau
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?
The possibility to set starting page-numbers for bookparts is
frequently requested, but not yet done.
Is the following not sufficient?

#(define-markup-command (bookpart-page-number layout props) ()
(let ((first-page-number (ly:output-def-lookup layout 'first-page-number))
(page-number (chain-assoc-get 'page:page-number props 0)))
(interpret-markup layout props (format "~a" (1+ (- page-number
first-page-number))))))

I use it all the time — along with some conditionals around it — and that’s sufficient for my needs. It doesn’t allow setting the the page-number arbitrarily, but I use it whenever I need the pages in each bookpart to start at 1 and number sequentially from there.

Hope this helps!
Kieren.

p.s. Of course, it would be great to have a much more robust and flexible numbering system… so maybe Harm’s code is a good beginning in that direction.
________________________________

Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: ***@kierenmacmillan.info
Michael Gerdau
2016-10-27 11:07:52 UTC
Permalink
Post by Thomas Morley
The possibility to set starting page-numbers for bookparts is
frequently requested, but not yet done.
In that case it seems the documentation is a least misleading. Under
http://lilypond.org/doc/v2.19/Documentation/notation/the-paper-block
it states that a \paper block can appear inside a \bookpart block
and under
http://lilypond.org/doc/v2.19/Documentation/notation/other-paper-variables#paper-variables-for-page-numbering
there is a paragraph "Known issues and warnings" that only talks about
even and odd numbers, left and right etc.

There probably should be mentioning that some variables have no effect
inside certain blocks.
Post by Thomas Morley
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.
[extensive code example snipped]

Thanks alot, helpful as always :)
I will have a look at it. Also thanks to Kieren for the briefish
solution to my problem at hand. Much appreciated.

Kind regards,
Michael
--
Michael Gerdau email: ***@qata.de
GPG-keys available on request or at public keyserver
Continue reading on narkive:
Search results for 'Problem controlling page numbers in bookparts' (Questions and Answers)
16
replies
Do you think that Jehovah's Witnesses are wrong?
started 2012-03-26 18:51:50 UTC
religion & spirituality
Loading...