[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Table-of-contents subheadings on separate pages
From: |
Valentin Petzel |
Subject: |
Re: Table-of-contents subheadings on separate pages |
Date: |
Sun, 09 Oct 2022 14:06:46 +0200 |
Hello Brent,
you could try to go for separate tocs for each subheading, like this:
\version "2.22.2"
#(define (symbol-or-false-or-procedure? x) (or (symbol? x) (not x) (procedure?
x)))
%% Copied from LilyPond's definition and modified
% @param printtitle If #f no title is printed
% @param filterfn can be
% A) A symbol (filter on label == filterfn)
% B) A procedure (filter on (filterfn tocitem))
% C) #f (Do not filter)
#(define-markup-list-command (filtered-table-of-contents layout props
printtitle
filterfn)
(boolean? symbol-or-false-or-procedure?)
#:properties ((baseline-skip))
(let* ((titleMarkup (ly:output-def-lookup layout 'tocTitleMarkup))
(indentMarkup (ly:output-def-lookup layout 'tocIndentMarkup))
(toplevelFormatter (ly:output-def-lookup layout 'tocFormatMarkup))
(toc-alist (toc-items))
(filtered-toc-alist
(if filterfn
(if (symbol? filterfn)
(filter
(lambda (item) (eq? filterfn (assoc-get 'name (cdr item))))
toc-alist)
(filter filterfn toc-alist))
toc-alist)))
(ly:output-def-set-variable! layout 'label-alist-table
(append (ly:output-def-lookup layout 'label-
alist-table)
toc-alist))
(if printtitle
(cons (interpret-markup layout props titleMarkup)
(space-lines baseline-skip
(map (lambda (toc-item)
(let* ((label (car toc-item))
(alist (cdr toc-item))
(toc-markup (assoc-get 'toc-markup
alist))
(text (assoc-get 'text alist))
(level (assoc-get 'level alist)))
(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)
(cons 'toc:level level)
(cons 'toc:toplevel-formatter
toplevelFormatter)
(cons 'toc:indent
(make-line-markup
(make-list level
indentMarkup))))
props)
(ly:output-def-lookup layout toc-
markup))))
filtered-toc-alist)))
(space-lines baseline-skip
(map (lambda (toc-item)
(let* ((label (car toc-item))
(alist (cdr toc-item))
(toc-markup (assoc-get 'toc-markup alist))
(text (assoc-get 'text alist))
(level (assoc-get 'level alist)))
(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)
(cons 'toc:level level)
(cons 'toc:toplevel-formatter
toplevelFormatter)
(cons 'toc:indent
(make-line-markup
(make-list level
indentMarkup))))
props)
(ly:output-def-lookup layout toc-markup))))
filtered-toc-alist)))))
#(define subtoxies '())
tocSub =
#(define-music-function (parser location id text) (symbol? markup?)
(set! subtoxies (cons id subtoxies))
(add-toc-item! 'tocSubMarkup text id))
tocIns =
#(define-music-function (parser location text) (markup?)
(add-toc-item! 'tocInsMarkup text))
%%%%%%%%%%%%%
\paper {
tocSubMarkup = \markup \large \column {
\hspace #1
\fill-line { \null \fontsize #3 \bold \fromproperty #'toc:text \null }
\hspace #1
\vspace #1 }
tocInsMarkup = \markup { \fontsize #1.5 \italic \fromproperty #'toc:text }
tocTitleMarkup = \markup \bold \column {
\fill-line { \null \fontsize #8 \underline "Table of Contents" \null }
\hspace #1
\vspace #1 }
tocItemMarkup = \markup {\fontsize #1.5 \italic \tocItemWithDotsMarkup }
}
scoreOne = \bookpart {
\tocSub #'toc1 \markup "Subtitle 1"
\tocItem #'toc1 \markup "List of items 1"
\score { \relative c' {c1} }
}
scoreTwo = \bookpart {
\tocSub #'toc2 \markup "Subtitle 2"
\tocItem #'toc2 \markup "List of items 2"
\score { \relative c' {c1} }
}
scoreThree = \bookpart {
\tocSub #'toc3 \markup "Subtitle 3"
\tocItem #'toc3 \markup "List of items 3"
\score { \relative c' {c1} }
}
$@(apply append
(map (lambda (x printtitle)
(list #{ \markuplist \filtered-table-of-contents #printtitle #x
#}
#{ \pageBreak #}))
(reverse subtoxies)
(cons #t (make-list (1- (length subtoxies)) #f))
))
\bookpart { \scoreOne }
\bookpart { \scoreTwo }
\bookpart { \scoreThree }
Cheers,
Valentin
Am Samstag, 8. Oktober 2022, 09:35:34 CEST schrieb Brent Annable:
> Hi all,
>
> I'm just wondering if there's a way to get each subheading in a table of
> contents to automatically appear on a new page? My table of contents is
> divided into three sections, and I would like each section to start on a
> new page:
>
> \version "2.22.1"
> \paper {
> tocSubMarkup = \markup \large \column {
> \hspace #1
> \fill-line { \null \fontsize #3 \bold \fromproperty #'toc:text \null }
> \hspace #1
> \vspace #1 }
>
> tocInsMarkup = \markup { \fontsize #1.5 \italic \fromproperty #'toc:text }
>
> tocTitleMarkup = \markup \bold \column {
> \fill-line { \null \fontsize #8 \underline "Table of Contents" \null }
> \hspace #1
> \vspace #1 }
> tocItemMarkup = \markup {\fontsize #1.5 \italic \tocItemWithDotsMarkup }
> }
>
> tocSub =
> #(define-music-function (parser location text) (markup?)
> (add-toc-item! 'tocSubMarkup text))
>
> tocIns =
> #(define-music-function (parser location text) (markup?)
> (add-toc-item! 'tocInsMarkup text))
>
>
> scoreOne = \bookpart {
> \tocSub \markup "Subtitle 1"
> \tocItem \markup "List of items 1"
> \score { \relative c' {c1} }
> }
>
> scoreTwo = \bookpart {
> \tocSub \markup "Subtitle 2"
> \tocItem \markup "List of items 2"
> \score { \relative c' {c1} }
> }
>
> scoreThree = \bookpart {
> \tocSub \markup "Subtitle 3"
> \tocItem \markup "List of items 3"
> \score { \relative c' {c1} }
> }
>
> \markuplist \table-of-contents
>
> \bookpart { \scoreOne }
> \bookpart { \scoreTwo }
> \bookpart { \scoreThree }
>
> Thanks for any help,
>
> Brent.
signature.asc
Description: This is a digitally signed message part.