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 d |
    e4 r8
    <<
      { f8 c c }
      \new Staff {
        f8 f c
      }
    >>
    r4 |
  }
}

[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 d |
    e4 r8
    <<
      { f8 c c }
      \new Staff \with {
        alignAboveContext = "main"
      } { f8 f c }
    >>
    r4 |
  }
}

[image of music]

This example uses \with, which will be explained more fully later. 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 are often written without clef and without time signature and are usually in a smaller font. These require further commands which have not yet been introduced. See Size of objects, and Ossia staves.


LilyPond — Learning Manual v2.24.4 (stable-branch).