Jump to content

Measure counters: Difference between revisions

From LilyPond wiki
m New category
Tags: Mobile edit Mobile web edit
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
The engraver must be added to the appropriate context. Here, a <code>Staff</code> context is used; another possibility is a <code>Dynamics</code> context.
The engraver must be added to the appropriate context. Here, a <code>Staff</code> context is used; another possibility is a <code>Dynamics</code> context.


The counter is begun with <code>\startMeasureCount</code> and ended with <code>\stopMeasureCount</code>. Numbering will start by default with 1, but this behavior may be modified by overriding the <code>count-from</code> property.
The counter is begun with <code>\startMeasureCount</code> and ended with <code>\stopMeasureCount</code>. Numbering will start by default with&nbsp;1, but this behavior may be modified by overriding the <code>count-from</code> property.


When a measure extends across a line break, the number will appear twice, the second time in parentheses.
When a measure extends across a line break, the number will appear twice, the second time in parentheses.


<lilypond version="2.24" full>
<lilypond version="2.24">
\layout {
\layout {
   \context {
   \context {
Line 37: Line 37:
   \stopMeasureCount
   \stopMeasureCount
}
}
\paper { tagline = ##f }
</lilypond>
</lilypond>


[[Category:Included in the official documentation]]
[[Category:Contexts and engravers]]
[[Category:Contexts and engravers]]
[[Category:Editorial annotations]]
[[Category:Editorial annotations]]
[[Category:Repeats]]
[[Category:Repeats]]
[[Category:Staff notation]]
[[Category:Staff notation]]
[[Category:Included in the official documentation]]
[[Category:Snippet]]
[[Category:Snippet]]

Latest revision as of 09:42, 4 December 2025

This snippet demonstrates the use of the Measure_counter_engraver to number groups of successive measures. Any stretch of measures may be numbered, whether consisting of repetitions or not.

The engraver must be added to the appropriate context. Here, a Staff context is used; another possibility is a Dynamics context.

The counter is begun with \startMeasureCount and ended with \stopMeasureCount. Numbering will start by default with 1, but this behavior may be modified by overriding the count-from property.

When a measure extends across a line break, the number will appear twice, the second time in parentheses.

\version "2.24"

\layout {
  \context {
    \Staff
    \consists #Measure_counter_engraver
  }
}

\new Staff {
  \startMeasureCount
  \repeat unfold 7 {
    c'4 d' e' f'
  }
  \stopMeasureCount
  \bar "||"
  g'4 f' e' d'
  \override Staff.MeasureCounter.count-from = #2
  \startMeasureCount
  \repeat unfold 5 {
    g'4 f' e' d'
  }
  g'4 f'
  \bar ""
  \break
  e'4 d'
  \repeat unfold 7 {
    g'4 f' e' d'
  }
  \stopMeasureCount
}