4.1.3 Nesting music expressions

It is not essential to declare all staves at the beginning; they may be introduced temporarily at any point. This is particularly useful for creating ossia sections – see ossia. Here is a simple example showing how to introduce a new staff temporarily for the duration of three notes:

\new Staff {
  \relative {
    r4 g'8 g c4 c8 e |
    <<
      { c4 c }
      \new Staff { d4 c }
    >>
    r2 |
  }
}

[image of music]

Note that the size of the clef is the same as a clef printed following a clef change – slightly smaller than the clef at the beginning of the line. This is usual for clefs printed in the middle of a line.

The ossia section may be placed above the staff as follows:

\new Staff = "main" {
  \relative {
    r4 g'8 g c4 c8 e |
    <<
      { c4 c }
      \new Staff \with {
        alignAboveContext = "main"
      } { d4 c }
    >>
    r2 |
  }
}

[image of music]

This example uses \with, which will be explained later in more detail. It is a means of modifying the default behavior of a single staff. Here it says that the new staff should be placed above the staff called “main” instead of the default position, which is below.

See also

Ossia staves are often written without clef and without time signature and are usually printed at a smaller size. Achieving this requires further commands, which have not yet been introduced. See Size of objects, and Ossia staves.


LilyPond Learning Manual v2.25.20 (development-branch).