Jump to content

Placing rehearsal marks other than above the top staff

From LilyPond wiki
Revision as of 08:44, 6 January 2026 by Lemzwerg (talk | contribs) (Remove outdated stuff)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This snippet defines a custom MarkLine context to display all metronome and rehearsal marks, and which may be inserted anywhere between staves or other lines in a score.

\version "2.24"

% LSR https://lists.gnu.org/archive/html/lilypond-user/2012-01/msg00556.html

global = {
  \tempo "Largo" 4=30 s1*2 |
  \mark \default s1*2 |
}

foo = \relative c' {
  c4 d e f |
  g f e d |
  c e g b |
  d2 c2 |
}

\score {
  <<
    \new Staff << \global \foo >>
    \new MarkLine \global
    \new Staff << \global \foo >>
    \new MarkLine \global
    \new Staff << \global \foo >>
  >>
  \layout {
    \context {
      \name "MarkLine"
      \type "Engraver_group"
      \consists Output_property_engraver
      \consists Axis_group_engraver
      \consists Mark_engraver
      \consists Metronome_mark_engraver
      \consists Staff_collecting_engraver
      \override RehearsalMark.extra-spacing-width = #'(0 . 1)
      \override MetronomeMark.extra-spacing-width = #'(0.5 . 0)
      \override VerticalAxisGroup.minimum-Y-extent = #'(-2 . 2)
      \override VerticalAxisGroup.staff-staff-spacing =
        #'((basic-distance . 1)
           (minimum-distance . 1)
           (padding . 1)
           (stretchability . 3))
    }
    \context {
      \Score
      \remove Mark_engraver
      \remove Metronome_mark_engraver
      \remove Staff_collecting_engraver
      \accepts MarkLine
    }
  }
}