3.7 Das Inhaltsverzeichnis flexibel einsetzen

Diese Funktionen existieren schon im OrchestraLily-Paket:


Um den Text flexibler behandeln zu können, bevorzugen manche Benutzer es, das Inhaltsverzeichnis aus LilyPond zu exportieren und dann mit LaTeX einzulesen.

Das Inhaltsverzeichnis (ToC) aus LilyPond exportieren

Hier wird angenommen, dass in Ihrer Partitur mehrere Sätze vorkommen, die sich alle in der selben LilyPond-Datei befinden.

#(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))))
             (formatted-toc-items (map format-line (toc-items)))
             (whole-string (string-join formatted-toc-items ",\n"))
             (output-name (ly:parser-output-name))
             (outfilename (format #f "~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)))))

\paper {
  #(define (page-post-process layout pages) (oly:create-toc-file layout pages))

Das Inhaltsverzeichnis in LaTeX importieren

In der LaTeX-Datei sollte folgendes enthalten:


wobei \includescore wiefolgt definiert ist:

% \includescore{PossibleExtension}

% Read in the TOC entries for a PDF file from the corresponding .toc file.
% This requires some heave latex tweaking, since reading in things from a file
% and inserting it into the arguments of a macro is not (easily) possible

% Solution by Patrick Fimml on #latex on April 18, 2009:
% \readfile{filename}{\variable}
% reads in the contents of the file into \variable (undefined if file
% doesn't exist)
{\catcode`\^^M=10\global\read\readfile@f to \readfile@tmp}%
\openin\readfile@f=#1 %
\typeout{No TOC file #1 available!}%


LilyPond – Usage v2.22.1 (stabiler Zweig).