Es wird
automatisch ein file ausgegeben. Es trägt den Namen "file.toc", wobei file der Name des files ist in dem dieser code angwendet wird.
Der Code stammt ursprünglich von Rainhold Kainhofer, der ihn seinen Bedürfnissen angepasst hatte und war dann lange in Vergessenheit geraten.
Man kann ihn natürlich neu anpassen, hier ein volles Beispiel, mit klitze-kleinen Veränderungen:
\version "2.18.2"
#(define (oly:create-toc-file layout pages)
(let* ((label-table (ly:output-def-lookup layout 'label-page-table)))
(if (not (null? label-table))
(let* ((format-line (lambda (toc-item)
(let* ((label (car toc-item))
(text (caddr toc-item))
(label-page (and (list? label-table)
(assoc label label-table)))
(page (and label-page (cdr label-page))))
;(format #f "~a, section, 1, {~a}, ~a" page text label)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(format #f "~a, ~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 "page, text, label\n" outfile))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(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)))))
\paper {
#(define (page-post-process layout pages) (oly:create-toc-file layout pages))
}
{
\tocItem "auf Seite 1"
c'1
\pageBreak
\tocItem "auf Seite 2"
d'
\pageBreak
\tocItem "auf Seite 3"
e'
}
Wenn Du das als atest-40.ly abspeicherst und compilierst, so ensteht atest-40.pdf wie üblich sowie atest-40.toc im selben Ordner. Das zweite allerdings ohne Meldung im Terminal. Kann man natürlich auch haben, wenn gewünscht.
atest-40.toc hat dann folgenden Inhalt:
page, text, label
1, auf Seite 1, toc99,
2, auf Seite 2, toc100,
3, auf Seite 3, toc101
Was genau dahin geschrieben wird könnte natürlich ebenfalls noch angepasst werden.
Aber erstmal soweit, hth,
Harm