On 2022-09-05 7:29 am, Adam M. Griggs wrote:
[ . . . ]
Given this rough mockup of the wanted end result, is it possible for me
to
automatically generate such a ToC?
It requires working around some limitations of the built-in \tocItem.
Importantly, \tocItem only supports providing a single markup for each
item. As such, \table-of-contents will only output two columns of data:
the text for an item and its page number.
Short of ripping out the guts of \table-of-contents and allowing a more
flexible input format, we can cheat a little. The text of each item is
itself markup, so you can provide much more than just a simple bit of
text. If we cram two pieces of data into that field, the final table of
contents will appear to have three columns of data.
The main limitation is that we have to split up the formatting of each
line into two parts. So this requires careful coordination to ensure
things lay out as expected.
Here is just one way of doing this:
%%%%
\version "2.22.0"
\paper {
myTocItemMarkup = \markup
\fill-line {
\null
\override #'(line-width . 50)
\overlay {
\tiny \fill-with-pattern #0.75 #RIGHT "." \null \null
\fill-line \larger {
\fromproperty #'toc:text
\override #'(style . outline)
\override #'(thickness . 3) \whiteout
\fromproperty #'toc:page
}
}
\null
}
tocDividerMarkup = \markup
\pad-around #3
\fill-line { \null ". . ." \null }
}
myTocItem =
#(define-music-function
(piece parts)
(markup? markup?)
(add-toc-item!
'myTocItemMarkup
#{
\markup \concat {
\with-dimensions-from \hspace #20
\override #'(thickness . 2) \whiteout
$piece
\override #'(thickness . 2) \whiteout
$parts
}
#}
'()))
tocDivider =
#(define-music-function () ()
(add-toc-item! 'tocDividerMarkup "" '()))
\book {
\markuplist \table-of-contents
\myTocItem "Piece I" "SSAA"
\markup \null \pageBreak
\myTocItem "Piece I" "SATB"
\markup \null \pageBreak
\myTocItem "Piece II" "SSAA"
\markup \null \pageBreak
\markup \null \pageBreak
\myTocItem "Piece II" "SATB"
\markup \null \pageBreak
\markup \null \pageBreak
\markup \null \pageBreak
\myTocItem "Piece II" "TTBB"
\markup \null \pageBreak
\markup \null \pageBreak
\markup \null \pageBreak
\markup \null \pageBreak
\markup \null \pageBreak
\tocDivider
\myTocItem \markup \bold "Piece XXVI"
\markup \italic "SSAATTBB"
\markup \null
}
%%%%
-- Aaron Hill