[ << lilypond-book ] | [Racine][Table des matières][Index] | [ Programmes externes >> ] |
[ < ] | [Plus haut: lilypond-book ] | [ Autres méthodes d'association texte-musique > ] |
3.7 Gestion de la table des matières
Les fonctions ici mentionnées sont incluses dans le paquetage OrchestralLily, disponible sur
https://repo.or.cz/w/orchestrallily.git
Certains utilisateurs privilégient la flexibilité dans la gestion du texte ; ils génèrent la table des matières à partir de LilyPond et la récupèrent dans LaTeX.
Export de la table à partir de LilyPond
Nous partons du principe que LilyPond a généré un seul fichier comportant tous les mouvement de la partition.
#(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 (G_ "Impossible d'ouvrir le fichier ~a contenant les informations de TdM") outfilename)) (close-output-port outfile))))) \paper { #(define (page-post-process layout pages) (oly:create-toc-file layout pages)) } |
Import de la table dans LaTeX
L’entête de votre fichier LaTeX doit comporter les lignes
\usepackage{pdfpages} \includescore{nomdelapartition} |
où \includescore
est défini ainsi :
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \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) \newread\readfile@f \def\readfile@line#1{% {\catcode`\^^M=10\global\read\readfile@f to \readfile@tmp}% \edef\do{\noexpand\g@addto@macro{\noexpand#1}{\readfile@tmp}}\do% \ifeof\readfile@f\else% \readfile@line{#1}% \fi% } \def\readfile#1#2{% \openin\readfile@f=#1 % \ifeof\readfile@f% \typeout{No TOC file #1 available!}% \else% \gdef#2{}% \readfile@line{#2}% \fi \closein\readfile@f% }% \newcommand{\includescore}[1]{ \def\oly@fname{\oly@basename\@ifmtarg{#1}{}{_#1}} \let\oly@addtotoc\undefined \readfile{\oly@xxxxxxxxx}{\oly@addtotoc} \ifx\oly@addtotoc\undefined \includepdf[pages=-]{\oly@fname} \else \edef\includeit{\noexpand\includepdf[pages=-,addtotoc={\oly@addtotoc}] {\oly@fname}}\includeit \fi } |
[ << lilypond-book ] | [Racine][Table des matières][Index] | [ Programmes externes >> ] |
[ < ] | [Plus haut: lilypond-book ] | [ Autres méthodes d'association texte-musique > ] |