Hiding staves

Staff lines can be hidden by removing the Staff_symbol_engraver from the Staff context. As an alternative, \stopStaff may be used.

\new Staff \with {
  \remove Staff_symbol_engraver
}
\relative { a''8 f e16 d c b a2 }

[image of music]

Empty staves can be hidden (for a so-called ‘Frenched Score’) by applying the \RemoveEmptyStaves command on a context, which can be done globally (in a \layout block) as well as for specific staves only (in a \with block). This command removes all empty staves in a score except for those in the first system. If you want those in the first system to be hidden also, use \RemoveAllEmptyStaves.

\layout {
  \context {
    \Staff
    \RemoveEmptyStaves
  }
}

\relative <<
  \new Staff {
    e'4 f g a \break
    b1 \break
    a4 b c2
  }
  \new Staff {
    c,4 d e f \break
    R1 \break
    f4 g c,2
  }
>>

[image of music]

A staff is considered empty when it contains only multi-measure rests, rests, skips, or a combination of these elements. All other musical objects (that cause a staff not to be considered as empty) are listed in the keepAliveInterfaces context property, as initially set in the ly/engraver-init.ly file.

\RemoveEmptyStaves and \RemoveAllEmptyStaves are both predefined shortcuts that set such properties as remove-empty and remove-first for the VerticalAxisGroup object, as explained in Context modification identifiers.

The Keep_alive_together_engraver allows groups of staves to only be removed together and not individually. By default, it is part of the PianoStaff context: a piano part will only be hidden when both of its staves are empty. Similarly, a common engraving practice in orchestral scores is to remove empty groups of staves rather than individual staves; that can be achieved by adding the Keep_alive_together_engraver to the relevant staff grouping context, as explained Modifying context plug-ins (see Grouping staves for the context names).

\layout {
  \context {
    \StaffGroup
    \RemoveEmptyStaves
    \consists Keep_alive_together_engraver
  }
}

In the following example, staves devoted to wind instruments are removed in the second system; however, the double bass is not, because it is part of the string section, which is playing.

[image of music]

The Keep_alive_together_engraver internally uses the remove-layer property of a staff’s VerticalAxisGroup to decide whether to print it or not when it is considered empty. That property may also be set directly, in which case it acts as a priority index: values closest to zero take precedence over higher numbers, and thus staves whose remove-layer is higher will be masked in favor of staves of a lower number.

This is particularly useful for ‘divisi’ staves, where some individual parts (see Writing parts) occasionally need to be expanded to more than one staff. In the following example, two parts are routed to three staves; however, all three staves are never printed at the same time:

Such substitutions are applied not just to notes, chords and other musical events that occur immediately after the new setting, but to the whole system where it takes place.

\layout {
  short-indent = 2\cm
  indent = 3\cm
  \context {
    \Staff
    keepAliveInterfaces = #'()
  }
}

violI = {
  \repeat unfold 24 { d'4 }
  \once \unset Staff.keepAliveInterfaces
  <d' g''>2
  \repeat unfold 14 { d'4 }
  \bar "|."
}

violII = {
  \repeat unfold 24 { g4 }
  <g d'>2
  \repeat unfold 14 { g4 }
  \bar "|."
}

\new StaffGroup \with { \consists Keep_alive_together_engraver } <<
  \new Staff \with {
    instrumentName = "Violins"
    shortInstrumentName = "V I & II"
    \override VerticalAxisGroup.remove-layer = 2
  } <<  \violI \\ \violII  >>
  \new Staff \with {
    instrumentName = "Violin I"
    shortInstrumentName = "V I"
    \RemoveAllEmptyStaves
    \override VerticalAxisGroup.remove-layer = 1
  } \violI
  \new Staff \with {
    instrumentName = "Violin II"
    shortInstrumentName = "V II"
    \RemoveAllEmptyStaves
    \override VerticalAxisGroup.remove-layer = 1
  } \violII
>>

[image of music]

\RemoveAllEmptyStaves can also be used to create ossia sections for a staff. For details, see Ossia staves.

Predefined commands

\RemoveEmptyStaves, \RemoveAllEmptyStaves.

See also

Music Glossary: Frenched staff.

Learning Manual: Visibility and color of objects.

Notation Reference: Changing context default settings, Staff symbol, Ossia staves, Hidden notes, Invisible rests, Visibility of objects, Context modification identifiers, Grouping staves, Modifying context plug-ins.

Installed Files: ly/engraver-init.ly.

Snippets: Staff notation.

Internals Reference: ChordNames, FiguredBass, Lyrics, Staff, VerticalAxisGroup, Staff_symbol_engraver, Axis_group_engraver, Keep_alive_together_engraver.

Known issues and warnings

Removing Staff_symbol_engraver also hides bar lines. If bar line visibility is forced, formatting errors may occur. In this case, use the following overrides instead of removing the engraver:

\omit StaffSymbol
\override NoteHead.no-ledgers = ##t

For the Known issues and warnings associated with \RemoveEmptyStaves see Changing context default settings.


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