Jump to content

Centering multi-measure rests: Difference between revisions

From LilyPond wiki
Import snippet from LSR
 
m New category
Tags: Mobile edit Mobile web edit
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
If you want to centre multi-measure rest numbers between the two staves in a piano staff, a custom context can help.
If you want to centre multi-measure rest numbers between the two staves in a piano staff, a custom context can help.


<lilypond version="2.24.0">
<lilypond version="2.24">
\layout {
\layout {
   \context {
   \context {
Line 50: Line 50:
[[Category:Rhythms]]
[[Category:Rhythms]]
[[Category:Contexts and engravers]]
[[Category:Contexts and engravers]]
[[Category:Snippet]]

Latest revision as of 23:13, 21 November 2025

If you want to centre multi-measure rest numbers between the two staves in a piano staff, a custom context can help.

\version "2.24"

\layout {
  \context {
    \name PianoMMR
    \type "Engraver_group"
    \inherit-acceptability PianoMMR Dynamics
    \consists "Axis_group_engraver"
    \override VerticalAxisGroup.staff-affinity = #CENTER
    \override VerticalAxisGroup.nonstaff-relatedstaff-spacing =
      #'((basic-distance . 1) (minimum-distance . 1) (padding . 0.5) (stretchability . 1))
    \consists "Multi_measure_rest_engraver"
    \hide MultiMeasureRest
    \override MultiMeasureRest.Y-extent = #empty-interval
    \override MultiMeasureRestNumber.Y-offset = #-1
  }
  \context {
    \PianoStaff
    \accepts PianoMMR
    \override VerticalAxisGroup.staff-staff-spacing.padding = #14
  }
}

musicOne = {
  \clef bass
  \key f \major
  \time 3/8
  \partial 8
  r8 | R4.*7 |
}

musicTwo = {
  \clef bass
  \key f \major
  \time 3/8
  \partial 8
  r8 | R4.*7 |
}

\new PianoStaff <<
  \new Staff \with { \omit MultiMeasureRestNumber } \compressMMRests \musicOne
  \new PianoMMR \musicOne
  \new Staff \with { \omit MultiMeasureRestNumber } \compressMMRests \musicTwo
>>