[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: TOC entries listed in order of \include
From: |
Vincent Gay |
Subject: |
Re: TOC entries listed in order of \include |
Date: |
Wed, 28 Sep 2022 10:47:07 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 |
Le 28/09/2022 à 09:30, Brent Annable a
écrit :
I
would be interested in seeing an example.
The code of the main file, not compilable (the bookparts are
missing), is copied at the end of this message, as well as an
example of bookpart
Below is a link to my book (work in progress) which contains for the
moment 87 pieces (which means 87 included files) that is 174
bookparts and 256 pages of music.
https://zzz.zaclys.com/remise/9c792b7e77a78f85b233ecbdf04096d6/2022-09-28_Recueil.zip
The sources are included in the pdf but if you want to compile note
that I use lilyJazz (you'll have to install the fonts) and some
special functions also contained in included file.
Also: what program is that you are using in the screenshot above?
For writing the TOC ? Lilypond, exclusively.
For reading pdf ? Okular. The presentation will be the same with
other (good) documents viewers as Evince (or Acrobat Reader).
Here another screenshot with Firefox
Lily's main code
%<----------------------------
\version "2.23.11"
\paper {
#(use-modules (ice-9 match)
(srfi srfi-1))
page-breaking =
#(lambda (paper-book)
(let* ((paper (ly:paper-book-paper paper-book))
(parent (ly:output-def-parent paper))
(top-paper (if (null? parent)
paper
parent))
(alist-before (ly:output-def-lookup top-paper
'label-page-table))
(result (ly:optimal-breaking paper-book))
(alist-after (ly:output-def-lookup top-paper
'label-page-table))
(alist-part (let loop ((after alist-after)
(acc '()))
(if (eq? after alist-before)
(reverse! acc)
(loop (cdr after)
(cons (car after)
acc)))))
(new-alist (let loop ((alist alist-part)
(acc '())
(same-pgnum '())
(last-pgnum #f))
(match alist
(()
(append-reverse same-pgnum acc))
(((label . page) . rest)
(if (or (not last-pgnum)
(eqv? last-pgnum page))
(loop rest
acc
(acons label page
same-pgnum)
page)
(loop rest
(append-reverse
same-pgnum acc)
(list (cons label page))
page)))))))
(ly:output-def-set-variable! top-paper 'label-page-table
(append-reverse new-alist alist-before))
result))
}
% Voir
https://lists.gnu.org/archive/html/lilypond-user-fr/2022-08/msg00074.html
% et https://gitlab.com/lilypond/lilypond/-/issues/6355
#(let ((default-table-of-contents
make-table-of-contents-markup-list))
(define-markup-list-command (table-of-contents layout props) ()
(let* ((result (interpret-markup-list layout props
(default-table-of-contents)))
(alist (ly:output-def-lookup layout 'label-alist-table))
(parent (ly:output-def-parent layout)))
(when (not (null? parent))
(ly:output-def-set-variable! parent 'label-alist-table
alist))
result)))
#(use-modules (ice-9 match))
#(define (group-to-fill-partial-sums lst weight threshold initial)
(let loop ((lst lst)
(i 0)
(partial-sum (initial 0))
(acc '()))
(match lst
(()
(reverse! (map reverse! acc)))
((elt . rest)
(let* ((elt-weight (weight elt))
(new-sum (+ partial-sum elt-weight)))
(cond
((null? acc)
(loop rest i new-sum (list (list elt))))
((<= new-sum threshold)
(loop rest i new-sum (cons (cons elt (car acc))
(cdr acc))))
(else
(loop rest
(1+ i)
(+ (initial (1+ i))
elt-weight)
(cons (list elt)
acc)))))))))
#(define (index-map f . lsts)
(let loop ((lsts lsts)
(i 0))
(if (any null? lsts)
'()
(cons (apply f i (map car lsts))
(loop (map cdr lsts)
(1+ i))))))
#(ly:register-stencil-_expression_ 'new-toc-group)
#(define-markup-command (new-toc-group layout props arg) (markup?)
(let* ((stil (interpret-markup layout props arg))
(expr (ly:stencil-expr stil))
(x (ly:stencil-extent stil X))
(y (ly:stencil-extent stil Y)))
(ly:make-stencil `(new-toc-group ,expr)
x
y)))
#(define-markup-list-command (multicolumn-toc layout props columns)
(index?)
#:properties ((baseline-skip)
(padding 5)
(line-width))
(let ((width (/ (- line-width (* padding (1- columns)))
columns))
(height (- (ly:output-def-lookup layout 'paper-height)
(ly:output-def-lookup layout 'top-margin)
(ly:output-def-lookup layout 'bottom-margin))))
(let ((mkup (ly:output-def-lookup layout 'tocItemMarkup)))
(ly:output-def-set-variable! layout 'tocItemMarkup
(make-override-markup
`(line-width . ,width)
mkup)))
(match-let*
(((title . ungrouped-unfiltered-stils)
(interpret-markup-list layout
props
(make-table-of-contents-markup-list)))
(ungrouped-stils (remove ly:stencil-empty?
ungrouped-unfiltered-stils))
(stils
(let loop ((ungrouped-stils ungrouped-stils)
(group '())
(acc '()))
(match ungrouped-stils
(()
(reverse!
(map (lambda (group-elts)
(let ((rev-group-elts (reverse!
group-elts)))
(stack-stencils Y DOWN baseline-skip
rev-group-elts)))
(cons group acc))))
((stil . rest)
(match (ly:stencil-expr stil)
(('new-toc-group expr)
(let* ((x (ly:stencil-extent stil X))
(y (ly:stencil-extent stil Y))
(unwrapped (ly:make-stencil expr x
y)))
(loop rest
(list unwrapped)
(cons group acc))))
(_
(loop rest
(cons stil group)
acc)))))))
(split (group-to-fill-partial-sums
stils
(lambda (stil)
(+ (interval-length (ly:stencil-extent stil Y))
baseline-skip))
height
(let ((title-height (interval-length
(ly:stencil-extent title Y))))
(lambda (i)
(if (< i columns)
title-height
0)))))
(cols (group-to-fill-partial-sums
split
(const 1)
columns
(const 0))))
(cons title
(map (lambda (page-cols)
(apply ly:stencil-add
(index-map
(lambda (i col-stils)
(ly:stencil-translate-axis
(stack-stencils Y DOWN baseline-skip
col-stils)
(* i (+ width padding))
X))
page-cols)))
cols)))))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Here a list of included files.ly containing the bookparts
% \include "file1.ly"
% \include "file2.ly"
% \include ...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\header {
meter = "For C instruments"
tagline = ##f
}
\paper {
ragged-last-bottom = ##t
ragged-last = ##f
system-system-spacing = #'((basic-distance . 18)
(minimum-distance . 12)
(padding . 0))
markup-system-spacing = #'((basic-distance . 30)
(minimum-distance . 8)
(padding . 1))
%% Attention : s'il y a plusieurs éléments à l'intérieur du
tocActMarkup,
%% ne pas faire \new-toc-group { ... } mais \new-toc-group \line {
... }
tocActMarkup = \markup \new-toc-group \line {
\vspace #1
\hspace #-4
\italic \fromproperty #'toc:text
}
tocGhostItemMarkup = ""
tocItemMarkup = \markup
\fontsize #-2
\fill-line {
\fill-with-pattern #1.5 #CENTER .
\line {
\hspace #-6.5 %% Cancelling the first level's tocIndentMarkup
\fromproperty #'toc:indent \fromproperty #'toc:text
\hspace #2
}
\fromproperty #'toc:page
}
tocTitleMarkup =
\markup {
\column {
\vspace #3
\fill-line { \fontsize #9 "The Lily Book " }
\vspace #0.5
\fill-line { \fontsize #2 "Vol.1 (pre-release)" }
\vspace #1
\fill-line { \fontsize #3 "For C Instruments" }
\vspace #1
\fill-line { "(with Lilypond sources included)" }
\vspace #2
}
}
}
tocAct =
#(define-music-function (label text) (symbol-list-or-symbol?
markup?)
(add-toc-item! 'tocActMarkup text label))
tocGhostItem =
#(define-music-function (label text) (symbol-list-or-symbol?
markup?)
(add-toc-item! 'tocGhostItemMarkup text label))
#(define-markup-command (hide layout props arg) (markup?)
(interpret-markup layout props arg)
empty-stencil)
\book {
\bookpart {
\header {
meter = ""
tagline = ##f
}
\tocGhostItem TOC "Table of Contents"
\paper { line-width = 18.0\cm }
\markuplist
% les \override sont facultatifs
\override #'(padding . 10)
\override #'(baseline-skip . 1 )
\multicolumn-toc #3
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Here is a list of bookparts contained in the files included above
% \bookpart { \BookPartI }
% \bookpart { \BookPartII }
% \bookpart { ... }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
%<----------------------------
Bookpart code example
%<----------------------------
\version "2.23.11"
title = #"Ethiopia"
composer = #"Larry Willis"
meter = #"(Slow Ballad)"
video = #"https://www.youtube.com/watch?v=LoTv1zw0ETM"
player = #"Larry Willis and Kenny Garrett"
realBookTitle = \markup {
\score {
{
\override TextScript.extra-offset = #'(0 . -4.5)
s4
s^\markup {
\fill-line {
\fontsize #1 \lower #1 \rotate #7 \concat { " " #meter }
\fontsize #4
\override #'(offset . 9)
\override #'(thickness . 6)
\underline \larger \larger #title
\fontsize #1 \lower #1 \concat { "Music from " #composer
" " }
}
}
s \bar "|"
}
\layout {
\omit Staff.Clef
\omit Staff.TimeSignature
\omit Staff.KeySignature
ragged-right = ##f
}
}
}
EthiopiaHeader = \header {
title = \realBookTitle
arranger = \markup \fontsize #-1 \pad-around #1 \underline
\with-url #video \concat { "(as played by " #player ")" }
}
musique = \relative c'' {
\clef "treble" \key es \major \time 3/4
\mark #1
d,4 es f | g2~ 8 f | g as f4. es8 | f8 g es4. c8 | \break
d2. | cis4 d e | f2. | g8 es bes'4. d8 | \break
a2.~ | 2~ \tuplet 3/2 { 8 g fis } | e2. ~ | 2. | \break
d'8 cis a2~ | 2.~ | 2.~ | 2. \break \bar "||" \mark #2
d,4 es f | g2 c4 | bes2 as4 | g2. | \break
g8 as4 c f,8 | d2.~ | 2. | c4 es d | \break
c2.~ | 2.~ | 2.~ | 4 r es8 d
c2.~ | 2.~ | 2.~ | 2.
\bar ".."
}
accordsI = \chordmode {
\set chordChanges = ##f
c2.:m7 s des:7+ s
}
accords = \chordmode {
\set chordChanges = ##f
as2.:7+11+/g as:7+ f:m7 des:7+ c:m7 fis:m7 f/g es/f
e:m7 s fis:7+11+ s e:m7 s fis:7+11+ s
as2.:7+11+/g f2:m7 bes4:7sus4 es2.:7+ as:7+ des:7+ as2.:7+11+/g s
s
c:m7 s des:7+ s c:m7 s des:7+ s
}
RH = \relative c'' {
\clef "treble" \key es \major \time 3/4
\showStartRepeatBar \bar "[|:"
\once \override Score.RehearsalMark.self-alignment-X = #LEFT
\mark \markup \box Intro
\repeat volta 2 {
<d e g>4 q q | <d f bes> q q | <c des f> q q |
<c des f as> q q
}
}
LH = \relative c {
\clef "bass" \key es \major \time 3/4
r8 c4 4 8~ | 8 4 4 8 | r8 as4 4 8~ | 8 4 4 8 |
}
grille = \chordmode {
\bar "[|:"
\once \override Score.RehearsalMark.self-alignment-X = #LEFT
\mark \markup \box Intro
\repeat volta 2 { \repeat percent 2 { c1:m7 } \repeat percent 2 {
des:7+ } } \break
\mark #1 as1:7+11+ as:7+ f:m7 des:7+ \break
c:m7 fis:m7 f/g es/f \break
\repeat volta 2 { \repeat percent 2 { e:m7 } \repeat percent 2 {
fis:7+11+ } }
\break \mark #2
as1:7+11+ f2.:m7 bes4:7sus4 es1:7+ as:7+ \break
des:7+ \repeat percent 3 { as1:7+11+ } \break
\repeat volta 2 { \repeat percent 2 { c:m7 } \repeat percent 2 {
des:7+ } }
}
EthiopiaPartI = \bookpart {
\EthiopiaHeader
\tocAct Ethiopia \markup "Ethiopia (Larry Willis)"
\tocItem Ethiopia.Lead \markup "Lead sheet"
\score {
<<
\new ChordNames \accordsI
\new PianoStaff \with { instrumentName = Piano } <<
\new Staff \RH
\new Staff \LH
>> >>
}
\score {
<<
\new ChordNames \accords
\new Staff \with { instrumentName = "Alto Sax" } \musique
>>
}
}
EthiopiaPartII = \bookpart {
\paperGrid
\EthiopiaHeader
\tocItem Ethiopia.Grid \markup "Chords Grid"
\new ChordGridScore <<
\new ChordGrid \grille
>>
}
--
Vincent Gay
Envoyé depuis mon saxo-phone :)
https://myrealbook.vintherine.org/ - http://photos.vintherine.org/