I tried to cc bug, but was rejected in first try.
Second attempt.
See thread:
http://lilypond.1069038.n5.nabble.com/2-Table-of-contents-in-same-source-file-td169322.html
---------- Forwarded message ----------
From: Thomas Morley <[email protected]>
Date: 2014-12-13 10:02 GMT+01:00
Subject: Re: 2 Table of contents in same source file
To: Helge Kruse <[email protected]>
Cc: Les Editions Valmajour <[email protected]>,
[email protected], Liste EN <[email protected]>
2014-12-11 6:28 GMT+01:00 Helge Kruse <[email protected]>:
> This looks like a bug for me. The toc-item-list holds the items inside
> toc-init,ly but there is no mean to reset the list.
>
> Could you move the two \book in separates files that \include the original
> content. In that case you have only one \book per file.
>
> Regards, Helge
Hi,
as Helge wrote the toc-items are accumalated per file.
The toc-item-list is cleared after one _entire_ session, so that
lilypond book-1.ly book-2.ly
will cause no bleed over.
(try to comment the line
(call-after-session (lambda () (set! toc-item-list '())))
in toc-init.ly to force such a bleed over)
Though, there is no mechanism in place to clear that list after one of
several books in the same ly-file.
Pity to say, it's beyond my depth to provide such a mechanism.
Looks like a bug for me too.
As a workaround I extended the code from toc-init.ly
Now you could (and should) specify the book you refer to while calling
\tocItem and add an override to table-of-contents
Syntax-example:
\include "my-toc-init.ly"
\book {
\markuplist \override #'(name . book-1) \table-of-contents
\score {
\tocItem #'book-1 \markup test1.1
\layout {}
}
\score {
\tocItem #'book-1 \markup test1.2
\layout {}
}
\score {
\tocItem #'book-1 \markup test1.3
\layout {}
}
}
Example-file and my-toc-init.ly attached
Please note:
Doing it this way call-after-session gives a (not surprising) error,
so I had to comment this line.
Ofcourse now you may experience bleed overs while compiling multiple
ly-files, if you _not_ specify the book.
HTH,
Harm
\version "2.19.13"
\include "my-toc-init.ly"
\book {
\markuplist \override #'(name . book-1) \table-of-contents
\score {
\tocItem #'book-1 \markup test1.1
\layout {}
}
\score {
\tocItem #'book-1 \markup test1.2
\layout {}
}
\score {
\tocItem #'book-1 \markup test1.3
\layout {}
}
}
\book {
\markuplist \override #'(name . book-2) \table-of-contents
\score {
\tocItem #'book-2 \markup test2.1
\layout {}
}
\score {
\tocItem #'book-2 \markup test2.2
\layout {}
}
\score {
\tocItem #'book-2 \markup test2.3
\layout {}
}
}
\book {
\markuplist \table-of-contents
\score {
\tocItem \markup test3.1
\layout {}
}
\score {
\tocItem \markup test3.2
\layout {}
}
\score {
\tocItem \markup test3.3
\layout {}
}
}
\version "2.19.13"
%% defined later, in a closure
#(define-public (add-toc-item! name markup-symbol text)
#f)
#(define-public (toc-items)
#f)
#(let ((toc-item-list (list)))
;(call-after-session (lambda () (set! toc-item-list '())))
(set! add-toc-item!
(lambda (name markup-symbol text)
(let ((label (gensym "toc")))
(set! toc-item-list
(cons (list label markup-symbol text name)
toc-item-list))
(make-music 'EventChord
'page-marker #t
'page-label label
'elements (list (make-music 'LabelEvent
'page-label label))))))
(set! toc-items (lambda ()
(reverse toc-item-list))))
\paper {
tocTitleMarkup = \markup \huge \column {
\fill-line { \null "Table of Contents" \null }
\null
}
tocItemMarkup = \markup \fill-line {
\fromproperty #'toc:text \fromproperty #'toc:page
}
}
tocItemWithDotsMarkup = \markup \fill-with-pattern #1 #RIGHT .
\fromproperty #'toc:text \fromproperty #'toc:page
#(define-markup-list-command (table-of-contents layout props) ()
#:properties ((name ""))
( _i "Outputs the table of contents, using the paper variable
@code{tocTitleMarkup} for its title, then the list of lines
built using the @code{tocItem} music function
Usage: @code{\\markuplist \\table-of-contents}" )
(let ((toc-items-ls (toc-items)))
(set! toc-items-ls (filter (lambda (x) (eq? (last x) name)) toc-items-ls))
(cons (interpret-markup layout props
(ly:output-def-lookup layout 'tocTitleMarkup))
(space-lines (chain-assoc-get 'baseline-skip props)
(map (lambda (toc-item)
(let ((label (car toc-item))
(toc-markup (cadr toc-item))
(text (caddr toc-item)))
(interpret-markup
layout
(cons (list (cons 'toc:page
(markup #:with-link label #:page-ref label "XXX" "?"))
(cons 'toc:text (markup #:with-link label text))
(cons 'toc:label label))
props)
(ly:output-def-lookup layout toc-markup))))
toc-items-ls)))))
tocItem =
#(define-music-function (parser location which text) ((symbol? "") markup?)
"Add a line to the table of content, using the @code{tocItemMarkup} paper
variable markup"
(add-toc-item! which 'tocItemMarkup text))
_______________________________________________
bug-lilypond mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-lilypond