Jump to content

Making bar numbers appear at regular intervals: 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 would like the bar numbers to appear at regular intervals, but not starting from measure zero, you can use a context function, <code>set-bar-number-visibility</code>, to set automatically <code>barNumberVisibility</code>, so that the bar numbers appear at regular intervals, starting from the measure in which <code>set-bar-number-visibility</code> is set using <code>\applycontext</code>.
If you would like the bar numbers to appear at regular intervals, but not starting from measure zero, you can use a context function, <code>set-bar-number-visibility</code>, to set automatically <code>barNumberVisibility</code>, so that the bar numbers appear at regular intervals, starting from the measure in which <code>set-bar-number-visibility</code> is set using <code>\applycontext</code>.


<lilypond version="2.24.0">
<lilypond version="2.24">
%% http://lsr.di.unimi.it/LSR/Item?id=91
%% http://lsr.di.unimi.it/LSR/Item?id=91


Line 26: Line 26:
[[Category:Tweaks and overrides]]
[[Category:Tweaks and overrides]]
[[Category:Text]]
[[Category:Text]]
[[Category:Snippet]]

Latest revision as of 23:23, 21 November 2025

If you would like the bar numbers to appear at regular intervals, but not starting from measure zero, you can use a context function, set-bar-number-visibility, to set automatically barNumberVisibility, so that the bar numbers appear at regular intervals, starting from the measure in which set-bar-number-visibility is set using \applycontext.

\version "2.24"

%% http://lsr.di.unimi.it/LSR/Item?id=91

resetBarnum = \context Score \applyContext #(set-bar-number-visibility 4)

\score {
    <<
         \transpose c c'' {
	    \override Score.BarNumber.break-visibility =#end-of-line-invisible
	    \override Score.RehearsalMark.padding = #2.5
	    \mark "A" \resetBarnum
	    \repeat unfold 10 c1
	    \mark \default \resetBarnum
	    \repeat unfold 8 c
            \bar "|."
        }
    >>
  \layout { ragged-right = ##t }
}