%% Generated by lilypond-book.py
%% Options: [exampleindent=10.16\mm,indent=0\mm,line-width=160\mm]
\include "lilypond-book-preamble.ly"


% ****************************************************************
% Start cut-&-pastable-section
% ****************************************************************



\paper {
  indent = 0\mm
  line-width = 160\mm
  % offset the left padding, also add 1mm as lilypond creates cropped
  % images with a little space on the right
  line-width = #(- line-width (* mm  3.000000) (* mm 1))
}

\layout {
  
}





% ****************************************************************
% ly snippet:
% ****************************************************************
\sourcefilename "/home/gub/gub/target/linux-x86/src/lilypond-git.sv.gnu.org--lilypond.git-stable-2.16/input/regression/scheme-book-scores.ly"
\sourcefileline 0
\version "2.16.0"

\header {

  texidoc = "Scores can be generated with scheme, too, and inserted into the
current book(part). Generated and explicit scores can be mixed, the header
informations from top- and booklevel stack correctly."

}

#(use-modules (scm display-lily))

% Sample score, which adds a score (containing just one note) to the current
% book/bookpart/at toplevel using scheme rather than the parser.
% That score is supposed to use the global header information, too.
#(define add-one-note-score 
   (let ((pitch 0))
        (lambda (parser)
          (let* ((scmpitch (ly:make-pitch 0 pitch 0))
                 (music (make-music 'EventChord
                          'elements (list (make-music 'NoteEvent
                                            'duration (ly:make-duration 2 0 1 1)
                                            'pitch scmpitch))))
                 (score (scorify-music music parser))
                 (layout (ly:output-def-clone $defaultlayout))
                 (desc (markup #:large #:line ((ly:format "Score with a ~a"
                                (note-name->lily-string scmpitch parser))))))
            (ly:score-add-output-def! score layout)
            (add-text parser desc)
            (add-score parser score))
            (set! pitch (modulo (1+ pitch) 7)))))

oneNoteScore =
#(define-music-function (parser location) ()
   (add-one-note-score parser)
   (make-music 'Music 'void #t))

%%%

\header {
  title = "Main Title"
  subtitle = "Main subtitle"
  piece = "Piecetitle"
}

\oneNoteScore

\bookpart {
  \header { title ="Title 1" subtitle="Sub1"}
  \oneNoteScore
  \score { \relative c' c1 }
  \oneNoteScore
}


\bookpart {
  \score { \relative c' c1 }
  \oneNoteScore
}

\oneNoteScore




% ****************************************************************
% end ly snippet
% ****************************************************************
