3.2.2 Multiple scores in a book

A document may contain multiple pieces of music and text. Examples of these are an etude book, or an orchestral part with multiple movements. Each movement is entered with a \score block,

\score {
  …music…
}

and texts are entered with a \markup block,

\markup {
  …text…
}

All the movements and texts which appear in the same .ly file will normally be typeset in the form of a single output file.

\score {
  
}
\markup {
  
}
\score {
  
}

One important exception is within lilypond-book documents, where you explicitly have to add a \book block, otherwise only the first \score or \markup will appear in the output.

The header for each piece of music can be put inside the \score block. The piece name from the header will be printed before each movement. The title for the entire book can be put inside the \book, but if it is not present, the \header which is at the top of the file is inserted.

\header {
  title = "Eight miniatures"
  composer = "Igor Stravinsky"
}
\score {
  \header { piece = "Romanze" }
  …
}
\markup {
   …text of second verse…
}
\markup {
   …text of third verse…
}
\score {
  \header { piece = "Menuetto" }
  …
}

Pieces of music may be grouped into book parts using \bookpart blocks. Book parts are separated by a page break, and can start with a title, like the book itself, by specifying a \header block.

\bookpart {
  \header {
    title = "Book title"
    subtitle = "First part"
  }
  \score { … }
  …
}
\bookpart {
  \header {
    subtitle = "Second part"
  }
  \score { … }
  …
}

By design, you cannot define variables within a \book or \bookpart block (the same is true for \score, by the way); this is especially relevant if you want to use multiple files to set up your music with variables that should be ‘local’ to single files. You can use the following structure for such situations.

% movement1.ly
variableI = { ... }
bookpartI = \bookpart { \score { ... use \variableI ... } }

% movement2.ly
variableII = { ... }
bookpartII = \bookpart { \score { ... use \variableII ... } }

% main.ly
\include "movement1.ly"
\include "movement2.ly"
\book {
  \bookpart { \bookpartI }
  \bookpart { \bookpartII }
}

Similarly, you can’t directly have a \layout block within \book or \bookpart. Put it into a \score block instead that is included by \book or \bookpart.


LilyPond Notation Reference v2.25.21 (development-branch).