lilypond-user
[Top][All Lists]
Advanced

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

Re: table-of-contents page links


From: Thomas Morley
Subject: Re: table-of-contents page links
Date: Sat, 28 Apr 2012 00:43:12 +0200

Am 27. April 2012 12:36 schrieb Jan-Peter Voigt <address@hidden>:
> Hello list,
>
> for some Books, I set the first page number to -1, to start page numbers
> with the real music.
> Now the PDF-internal links to the corresponding pages refer to the wrong
> page:
> If a tocItem displays page 8 it will open PDF-page 8 but that has the
> printed page-number 6, if its started with -1.
>
> Is this a bug, or can one tweak it?
>
> Cheers, Jan-Peter

Hi,

not sure it's a bug. It's the way \with-link works.

But you may want to redefine it. See code below.
I didn't manage to get acces to the `first-page-number' of \paper from
inside define-markup-command, so I used a work-around. Do you know how
to do?

%%%%%%%%%%%%%%%%%%%%%%%%%

\version "2.15.36"

#(define firstPageNumber -1)

#(define-markup-command (with-link layout props label arg)
  (symbol? markup?)
  (let* ((arg-stencil (interpret-markup layout props arg))
         (x-ext (ly:stencil-extent arg-stencil X))
         (y-ext (ly:stencil-extent arg-stencil Y)))
    (ly:make-stencil
     `(delay-stencil-evaluation
       ,(delay (ly:stencil-expr
                (let* ((table (ly:output-def-lookup layout 'label-page-table))
                       (orig-page-number (if (list? table)
                                        (assoc-get label table)
                                        #f))
                       (page-number (+ orig-page-number (+ 1 (* -1
firstPageNumber) )))
                       (link-expr (list 'page-link page-number
                                        `(quote ,x-ext) `(quote ,y-ext))))

                  (ly:stencil-add (ly:make-stencil link-expr x-ext y-ext)
      arg-stencil)))))
           x-ext
           y-ext)))

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%---- Test
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\paper {
          first-page-number = \firstPageNumber
  }

mus = \relative c'' {
        \repeat unfold 10 { c1 \break }
}

\book {
        \bookpart {
                \markup \bold \fontsize #10 \fill-line { "TITLE" }
        }

        \bookpart {
                \markup \fontsize #2 \fill-line { "Some Text" }
                
                \paper {
                        oddHeaderMarkup = \markup { \null }
                        evenHeaderMarkup = \markup { \null }
                }
        }
        \bookpart {
                \markuplist \table-of-contents
                
                \paper {
                        oddHeaderMarkup = \markup { \null }
                        evenHeaderMarkup = \markup { \null }
                }
        }
        \bookpart {
                \tocItem \markup { "Piece 1" }
                \score {
                        \mus
                        \header { piece = "Piece 1" }
                }
        }
        \bookpart {
                \tocItem \markup { "Piece 2" }
                \score {
                        \transpose c cis \mus
                        \header { piece = "Piece 2" }
                }
        }
        \bookpart {
                \tocItem \markup { "Piece 3" }
                \score {
                        \transpose c d \mus
                        \header { piece = "Piece 3" }
                }
        }
}

%%%%%%%%%%%%%%%%%%%%%%%%%


HTH,
  Harm



reply via email to

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