3 %% defined later, in a closure
4 #(define-public (add-toc-item! markup-symbol text)
6 #(define-public (toc-items)
9 #(let ((toc-item-list (list)))
10 (call-after-session (lambda () (set! toc-item-list '())))
12 (lambda (markup-symbol text)
13 (let ((label (gensym "toc")))
15 (cons (list label markup-symbol text)
17 (make-music 'EventChord
20 'elements (list (make-music 'LabelEvent
21 'page-label label))))))
22 (set! toc-items (lambda ()
23 (reverse toc-item-list))))
26 tocTitleMarkup = \markup \huge \column {
27 \fill-line { \null "Table of Contents" \null }
30 tocItemMarkup = \markup \fill-line {
31 \fromproperty #'toc:text \fromproperty #'toc:page
35 tocItemWithDotsMarkup = \markup \fill-with-pattern #1 #RIGHT .
36 \fromproperty #'toc:text \fromproperty #'toc:page
38 #(define-markup-list-command (table-of-contents layout props) ()
39 #:properties ((baseline-skip))
40 ( _i "Outputs the table of contents, using the paper variable
41 @code{tocTitleMarkup} for its title, then the list of lines
42 built using the @code{tocItem} music function
43 Usage: @code{\\markuplist \\table-of-contents}" )
44 (cons (interpret-markup layout props
45 (ly:output-def-lookup layout 'tocTitleMarkup))
46 (space-lines baseline-skip
47 (map (lambda (toc-item)
48 (let ((label (car toc-item))
49 (toc-markup (cadr toc-item))
50 (text (caddr toc-item)))
53 (cons (list (cons 'toc:page
54 (markup #:with-link label #:page-ref label "XXX" "?"))
55 (cons 'toc:text (markup #:with-link label text))
56 (cons 'toc:label label))
58 (ly:output-def-lookup layout toc-markup))))
62 #(define-music-function (text) (markup?)
63 "Add a line to the table of content, using the @code{tocItemMarkup} paper
65 (add-toc-item! 'tocItemMarkup text))