[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Three-column Table of Contents
From: |
Aaron Hill |
Subject: |
Re: Three-column Table of Contents |
Date: |
Mon, 05 Sep 2022 19:32:55 -0700 |
On 2022-09-05 5:12 pm, Adam M. Griggs wrote:
That's wonderful! Exactly what I was after, all the way down to the
internal hyperlinking.
Well, all of the linking work is part of the built-in table of contents
support in LilyPond.
For fun, though, I continued with the idea and came up with another
approach that might be a little more extensible. In this case, I
demonstrate support for three data fields (not including the page
number):
%%%%
\version "2.22.0"
\paper {
%% This is where you style an individual custom TOC item.
%% Custom properties like toc:first should exist here.
tocCustomItemMarkupInner =
\markup
\fill-line {
\line {
\hspace #12
\with-dimensions-from \hspace #1
\general-align #X #RIGHT \fromproperty #'toc:first
\bold \override #'(thickness . 2) \whiteout
\fromproperty #'toc:second
}
\italic \override #'(thickness . 2) \whiteout
\fromproperty #'toc:third
\fromproperty #'toc:page
}
%% This is mainly a wrapper that stuffs the desired formatting
%% above into a property that will be referenced by toc:text.
tocCustomItemMarkup =
\markup \overlay {
\fill-with-pattern #1 #RIGHT "." \hspace #13 \hspace #1
\override #(cons 'toc:inner tocCustomItemMarkupInner)
\fromproperty #'toc:text
}
}
tocCustomItem =
#(define-music-function
(first second third)
(markup? markup? markup?)
(add-toc-item!
'tocCustomItemMarkup
;; This is where all of the custom properties are given
;; their values. Note that we also reference toc:inner
;; which will get its value via tocCustomInnerMarkup.
#{ \markup \override #(cons 'toc:first first)
\override #(cons 'toc:second second)
\override #(cons 'toc:third third)
\fromproperty #'toc:inner #}
'()))
\markuplist
\override #'(line-width . 80)
\table-of-contents
\tocCustomItem lorem ipsum dolor
\markup \null \pageBreak
\tocCustomItem sit amet consectetur
\markup \null \pageBreak
\tocCustomItem adipisicing elit sed
\markup \null \pageBreak
\tocCustomItem do eiusmod tempor
\markup \null \pageBreak
\tocCustomItem incididunt ut labore
\markup \null \pageBreak
\tocCustomItem et dolore magna
\markup \null \pageBreak
\tocCustomItem aliqua ut enim
\markup \null
%%%%
-- Aaron Hill
toc2.cropped.png
Description: PNG image