lilypond-user
[Top][All Lists]
Advanced

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

Re: Make TOC entries available to LaTeX


From: Urs Liska
Subject: Re: Make TOC entries available to LaTeX
Date: Fri, 25 May 2018 08:42:00 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

Hi Federico,


Am 25.05.2018 um 08:28 schrieb Federico Bruni:


Il giorno ven 25 mag 2018 alle 7:55, Urs Liska <address@hidden> ha scritto:


Am 25. Mai 2018 07:48:58 MESZ schrieb Federico Bruni <address@hidden>:


Il giorno gio 24 mag 2018 alle 9:09, Urs Liska <address@hidden>
ha scritto:

 This is the function as it ended up in my project files:

 % Print table of contents entries to <basename>.toc
 % Based on
 %

http://lilypond.org/doc/v2.19/Documentation/usage-big-page#sharing-the-table-of-contents
 % Pointed to by "Thomas Morley"
 #(define (oly:create-toc-file layout pages)
    (let*
     ((label-table (ly:output-def-lookup layout 'label-page-table))
      (toc-items (toc-items)))
     (if (not (null? label-table))
         (let*
          ( ;; We need a page-offset so entries are offset to begin
 with p.1
            ;; (for use in \includepdf)
           (page-offset (- (ly:output-def-lookup layout
 'first-page-number) 1))
           (format-line
            (lambda (toc-item)
              (let*
               ((label (car toc-item))
                (text  (caddr toc-item))
                (page (- (assoc-ref label-table label) page-offset)))
               (format #f "~a,subsection,2,{~a},~a" page text
label))))
           (formatted-toc-items (map format-line toc-items))
           (whole-string (string-join formatted-toc-items ",\n"))
           (output-name (ly:parser-output-name))
           (outfilename (format "~a.toc" output-name))
           (outfile (open-output-file outfilename)))
          (if (output-port? outfile)
              (display whole-string outfile)
              (ly:warning (_ "Unable to open output file ~a for the
 TOC information") outfilename))
          (close-output-port outfile)))))

 page-offset calculates the offset of the first-page-number versus '1'

 and subtracts that from the actual page number of the TOC entry. That

 means when your score starts on page 16 a TOC item on the third page
 of the score will still get a TOC entry with page 3, and \includepdf
 will generate the appropriate TOC entry in the enclosing LaTeX
 document.

I get an error:

Drawing systems....brani.ly:35:23: In procedure - in _expression_ (-
(assoc-ref label-table label) page-offset):
brani.ly:35:23: Wrong type argument in position 1: #f

The offending line is:

(page (- (assoc-ref label-table label) page-offset)))

Can you tell what toc-item contains by inserting a display between the lambda and let lines immediately before that line?

I have a minimal example, see attachment.
The problem is triggered by wrapping each \tocItem within a \bookpart block (instead of the implicit \book, which works fine).

Here's what display shows:

Drawing systems.../home/fede/tmp/lilypond/toc-latex/test.ly:18:15: In procedure memoization in _expression_ (let* (# # #) (format #f "~a,subsection,2,{~a},~a" ...)):
/home/fede/tmp/lilypond/toc-latex/test.ly:18:15: In file "/home/fede/tmp/lilypond/toc-latex/test.ly", line 19: Bad binding (display text (caddr toc-item)) in _expression_ (let* ((label (car toc-item)) (display text (caddr toc-item)) (page (- (assoc-ref label-table label) page-offset))) (format #f "~a,subsection,2,{~a},~a" page text label)).


This is because you didn't place the (display between the lines with "lambda" and "let".

But I did some experiments, and I identified the problem but can't give you a solution.

When you have separate bookparts it seems the "label tables" are separate, so you have two label tables with one entry each. It seems they are associated with the corresponding "output definitions", but the function receives only one of them. When I print the contents of both toc-item and the label table I get the following results:

(toc99 tocItemMarkup A TOC entry)

((toc99 . 20))

(toc100 tocItemMarkup Another TOC entry)

((toc99 . 20))


which indicates one or several issues along the way which I hope someone else will be able to clarify (and suggest a solution).

Best
Urs
But the function is

reply via email to

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