lilypond-user
[Top][All Lists]
Advanced

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

Re: Creating TOC entry / page reference from inside a markup


From: Nicolas Sceaux
Subject: Re: Creating TOC entry / page reference from inside a markup
Date: Mon, 19 May 2008 22:30:37 +0200

Le 19 mai 08 à 18:05, Reinhold Kainhofer a écrit :

How can I add a TOC entry from inside a markup (or from a markup function)?

I tried
#(define-markup-command (piece-title layout props title) (markup?)
 (add-toc-item! 'tocItemMarkup title)
 (interpret-markup layout props (markup #:bold title))
)
but that does not add anything to the TOC :-(((

Nicolas' workaround is to call collect-music-for-book:

#(define-public (add-toc-item parser markup-symbol text)
 (collect-music-for-book parser
  (add-toc-item! markup-symbol text)))

but for this approach I need the parser, which I do not have available in the
markup command..
The reason I want this is that I automatically want all score titles to appear in the TOC, without having to duplicate the titles and manually insert loads
of tocItem calls.

This cannot work for two reasons:

1. you need to add to the list of toplevel objects (scores, markups, etc) a label. When the page breaker encounters such an object, it associates it to a page number, that's how the table of content can find out what
    page number should be printed for each item;

 2. At the time the code of the markup command is interpreted, the
    table-of-contents command has already queried the toc item list.

If you add the \markuplines \table-of-contents at the end of your file,
you will see that the items appear in the toc, but with question marks
instead of the page numbers, because the associated labels were not
inserted.

And you cannot use the (collect-music-for-book ...) hack because
it needs to be called during the file parsing (when top-level objects,
scores, markup, labels, are being collected); markup commands are
interpreted far later.

Labels cannot be inserted inside a markup, only at top-level or inside
music, and I see no way to do it.

(your second question is the same)

This may be kind of situation when one may consider using lilypond-book.

nicolas





reply via email to

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