lilypond-devel
[Top][All Lists]
Advanced

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

Re: Writing out a table of contents to a file


From: Nicolas Sceaux
Subject: Re: Writing out a table of contents to a file
Date: Sat, 11 Apr 2009 11:55:53 +0200

Le 11 avr. 09 à 00:01, Reinhold Kainhofer a écrit :
[...]
However, I would rather get the page information into latex's TOC instead and for this I need to write out the TOC entries to a separate file, preferrably
in the form
   page-number, "section", 1, title, toc-label
for each entry (since the addtotoc argument for the includepdf latex command
expects exactly such a list).

Now, it seems that I am unable to find a proper place where I have access to
the TOC entries list with the page numbers properly determined and
available...

Can anyone help me?


Maybe this will help you doing what you want:

\version "2.12.2"

\paper {
  #(set! write-page-layout #t)
  #(define (page-post-process layout pages)
(let ((label-table (ly:output-def-lookup layout 'label-page- table)))
       (format #t "~{~%~a~}"
         (map (lambda (toc-item)
                (let* ((label (car toc-item))
                       (text  (caddr toc-item))
                       (type  (cadr toc-item)) ;; more work to do here
(label-page (and (list? label-table) (assoc label label-table)))
                       (page (and label-page (cdr label-page))))
                  (format #f "~a, \"~a\", 1, ~s, ~a"
                    page type text label)))
              (toc-items)))))
}


\tocItem \markup "Toto"
\markup Toto
\pageBreak
\tocItem \markup "Titi"
\markup Titi
\pageBreak
\tocItem \markup "Tata"
\markup Tata


==>

1, "tocItemMarkup", 1, "Toto", toc53
2, "tocItemMarkup", 1, "Titi", toc54
3, "tocItemMarkup", 1, "Tata", toc55

You will have to transform the "tocItemMarkup", and also write the output
into a file rather than stdout.

Nicolas





reply via email to

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