Le 06/12/2022 à 19:05, Jean Abou Samra a écrit :
Le 06/12/2022 à 18:10, Joel C. Salomon a écrit :The requirement that `\tocItem` is either outside the `\score` block or within a music variable is making it awkward for me to keep it near where the score `\header` block defines the piece title. And I have entirely failed to figure out a way to re-use the piece title. Minimal example below, showing different ways I've tried. Is there a cleaner way to accomplish this?Try \version "2.23.82" upperI = \relative c' { c4 d e f } lowerI = \relative c {\clef bass f e d c } scoreI = \score { \header { piece = "Piece Title" } << \new Devnull { \tocItem \markup "Piece Title" } \new PianoStaff << \new Staff = "upper" \upperI \new Staff = "lower" \lowerI >> >> } \book { \markuplist \table-of-contents \scoreI } A \tocItem needs a bottom context to be interpreted, like a Voice, Dynamics, TabVoice or such. In this case, you don't want anything to be printed from it, so you can use this lesser known context type Devnull. Some people do it with a Dynamics as well. Devnull works with everything you might want to take out of the individual parts: \time, \tempo, \mark, etc. For not repeating the title between \header and \tocItem, you could try this approach: \version "2.23.82" withPiece = #(define-scheme-function (mkup score) (markup? ly:score?) (let* ((music (ly:score-music score)) (n (display-scheme-music music))
Sorry, the line above was for debugging, you can remove it.
(new-music #{ { \new Devnull \tocItem #mkup #music } #}) (new-score (ly:make-score new-music)) (header (let ((h (ly:score-header score))) (if (null? h) (make-module) h)))) (for-each (lambda (odef) (ly:score-add-output-def! new-score odef)) (ly:score-output-defs score)) (module-define! header 'piece mkup) (ly:score-set-header! new-score header) new-score)) upperI = \relative c' { c4 d e f } lowerI = \relative c {\clef bass f e d c } scoreI = \withPiece \markup "Piece Title" \score { \new PianoStaff << \new Staff = "upper" \upperI \new Staff = "lower" \lowerI >> } \book { \markuplist \table-of-contents \scoreI } Best, Jean
OpenPGP_signature
Description: OpenPGP digital signature