Very useful, I will test it. If this is a good implementation, maybe consider it for the next release?
2010/11/5 Jan-Peter Voigt <jp.vo...@gmx.de>: > Hello list, > > here is a snippet, wich creates footnotes. It is not tested very much!!! If > you like, try it and tell me how it works! If you have improvements, tell > the list :-) > I don't know what happens, when you use it extensibly in a large book with > several pages - if there are X pages and Y footnotes, the footer-items > markup has to loop X*Y through the list of notes! > I will try later ... > > First I was trying to get the piece field in the footer with several scores > in one bookpart. I looked through the lily-files in /usr/share and used some > code of toc-init.ly (\label) define-markup-commands.scm (\page-ref) and > thought of using a global running variable to keep this info available for > the footer ... > Then I received my first printed book of lily-scores I typesetted ( I am > 10cm larger now ;-) ) and I see, the piece info in the footer is not that > important. > But my tries made me think of footnotes. So I made this little script. > > Regards, > Jan-Peter > > --snip-- > \version "2.12.3" > > % Trying to get small(!) footnotes with excerpts from > define-markup-commands.scm and toc-init.ly > % This is a first try! > % TODO take gauge-stencil from page-width? > % TODO parameter for markup styles in paper{} (like 'tocItemMarkup) > % PROBLEM if there are X pages and Y footnotes, the footer-items markup has > to loop X*Y through the list of notes! > % PROBLEM the gauge-stencil always uses the same space! Also if there are no > notes on the page! > > % define the footnote counter > #(define footnr 0) > % to be defined in a closure later (see toc-init.ly) > #(define-public (add-foot-item! dir text) #f) > #(define-public (foot-items) #f) > > % define add item and get list functions > #(let ((foot-item-list (list))) > (set! add-foot-item! > (lambda (dir text) > (let ((label (gensym "foot"))) > (set! footnr (+ footnr 1)) > (set! foot-item-list > (cons (list label text footnr) > foot-item-list)) > (make-music 'EventChord > 'page-marker #t > 'page-label label > 'elements (list > (make-music 'LabelEvent 'page-label label) > (make-music 'TextScriptEvent 'direction dir 'text > (markup #:super #:circle (number->string footnr))) > ))))) > (set! foot-items (lambda () > (reverse foot-item-list)))) > > % conditionally add text markup, if we are on the right page > #(define (runfi pagelist cur-page table label text fnnr) > (let ((label-page (and (list? table) (assoc label table)))) > (if (and label-page (= cur-page (cdr label-page))) > (markup pagelist #:super (number->string fnnr) text) > pagelist > ) > ) > ) > > % define markup command to be used in footerMarkup > % delayed stencil-evaluation like in page-ref - so we know the pagenumber of > the label and the current page > % needs 'gauge'-stencil --- is hardcoded right now > #(define-markup-command (footer-items layout props)() > "markup footer items" > (let* ((gauge-stencil (interpret-markup layout props (markup #:super "1" > "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"))) > (x-ext (ly:stencil-extent gauge-stencil X)) > (y-ext (ly:stencil-extent gauge-stencil Y))) > (ly:make-stencil > `(delay-stencil-evaluation > ,(delay (ly:stencil-expr > > (let* ((table (ly:output-def-lookup layout > 'label-page-table)) > (cur-page (inexact->exact (string->number > (chain-assoc-get 'page:page-number-string props)))) > (pagelist (markup)) > (page-number -1)) > (map (lambda (fn) > (let ((label (car fn)) > (text (cadr fn)) > (fnnr (caddr fn))) > (set! pagelist (runfi pagelist > cur-page table label text fnnr)) > ) > ) (foot-items)) > (interpret-markup layout props (markup pagelist)) > ) > > ) > )) x-ext y-ext))) > % the footnote function > % takes direction (UP/DOWN) and markup > % other layout properties can be set via [\once] \override TextScript #'... > = ... > addfoot = #(define-music-function (parser location dir text)(integer? > markup?) > (begin (add-foot-item! dir text) > )) > > > \paper { > #(set-paper-size "a5" 'landscape) > oddHeaderMarkup = "" > evenHeaderMarkup = "" > oddFooterMarkup = \markup { \fill-line { > \concat { \fromproperty #'header:composer ", " \bold \fromproperty > #'header:title } > % fill in footer-items > \footer-items > \fromproperty #'page:page-number-string > } > } > evenFooterMarkup = \markup { \fill-line { > \fromproperty #'page:page-number-string > % fill in footer-items > \footer-items > \concat { \fromproperty #'header:composer ", " \bold \fromproperty > #'header:title } > } > } > } > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > % some really boaring music with \addfoot > > notenA = \relative c' { > \addfoot #UP \markup { "The C in the beginning is not confirmed!" } > \repeat unfold 24 { c d e f } > \addfoot #UP \markup { "This is started on G" } > { g( f e d) } > \repeat unfold 23 { c d e f } > \bar "|." > } > > \bookpart { > \header { > title = "title" > composer = "composer" > } > > \score { > \new Staff \new Voice { \notenA } > \header { > piece = "first" > } > } > \score { > \relative c' { > \repeat unfold 10 { c d e f } > \addfoot #0 \markup { "Test3" } > \repeat unfold 10 { c d e f } > \bar "|." > } > \header { > piece = "second" > } > } > } > \bookpart { > \header { > title = "Really boaring!!!!" > composer = "James the Chordbreaker" > } > \score { > << > \new Staff \new Voice = "voc" { > \relative c' { > \repeat unfold 10 { c d e f } > % override TextScript properties to move the number > \once \override TextScript #'self-alignment-X = #RIGHT > \once \override TextScript #'X-offset = #-2 > \addfoot #DOWN \markup { \italic "mi = \"la\" in ancient ork" } > \repeat unfold 10 { c d e f } > \bar "|." > } > } > \new Lyrics \lyricsto "voc" \lyricmode { > \repeat unfold 10 { la la la la } > \repeat unfold 10 { mi mi mi mi } > } >> > \header { > piece = "third" > } > } > } > > > _______________________________________________ > lilypond-user mailing list > lilypond-user@gnu.org > http://lists.gnu.org/mailman/listinfo/lilypond-user > _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user