Hello Stefano,

You might try to keep the whole thing dynamic and leave the numbering and 
stuff to Lilypond. For example you could have just a list of all Examples in 
one Category and then have a function to print that out. You could even do a 
list of Categories and print them all at once. This way you could even manage 
your Scores anyway you want, and adding Examples to one Group requires just 
adding it to that list. See the appended File for an example.

Cheers,
Valentin
catScore=
#(define-scheme-function (music number) (ly:music? number?)
   #{
     \score {
       \header {
         piece = \markup { Ex. #(number->string number) }
       }
       #music
       \layout { }
     }
   #})

addScore = #(define-void-function (score) (ly:score?) (add-score score)) 

catScores=
#(define-void-function (listOfScores i) (ly:music-list? number?)
   (if (not (null? listOfScores))
       (begin
         (add-score (catScore (car listOfScores) i))
         (catScores (cdr listOfScores) (+ i 1)))))
     

#(define catA (list
               #{ c'4 e'8 e' g' f' e'4 #}
               #{ d'4 4 16 16 e'8 g' d' #}
               #{ e'8 8 f' f' d' d' g4 #}))


\markup "Only printing one category this time"

\catScores #catA 1

#(define catB (list
               #{ \time 2/3 \times 2/3 { f'4 g' a' e' } #}
               #{ \new StaffGroup <<
                 \new Staff { c'8 d' e' f' e' d' c'4 } 
                 \new Staff {\clef bass c4 g f e }
               >> #}
               #{  \new TabStaff { e, g b e' } #}))

printCats=
#(define-void-function (listOfCategories) (list?)
   (if (not (null? listOfCategories))
       (begin
         (add-text
          #{
           \markup\larger\larger\larger { Category #(car (car listOfCategories)) }
          #})
         (catScores (cdr (car listOfCategories)) 1)
         (printCats (cdr listOfCategories)))))

#(define cats (list (cons "A" catA) (cons "B" catB)))

\markup "Printing all categories"

\printCats #cats

testm =\markup "test"
#(display testm)

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to