Jump to content

Aligning bar numbers

From LilyPond wiki

The default alignment of bar numbers depends on its position: at the beginning of a staff, bar numbers are right-aligned; at all other positions, they are left-aligned. Using Scheme function break-alignment-list, this can be changed; the three arguments of this function are the alignment for end-of-line, middle-of-line, and start-of-line position (in this order).

\version "2.24"

\relative c' {
  \set Score.currentBarNumber = 111
  \override Score.BarNumber.break-visibility = #all-visible
  % Increase the size of the bar number by 2
  \override Score.BarNumber.font-size = 2
  % Print a bar number every second measure
  \set Score.barNumberVisibility = #(every-nth-bar-number-visible 2)

  c1 | c1 | c1 | \break
  c1 | c1 | c1 | \break
  
  \override Score.BarNumber.self-alignment-X =
    #(break-alignment-list CENTER RIGHT CENTER)
  c1 | c1 | c1 | \break
  c1 | c1 | c1 |
}

\paper {
  line-width = 70\mm
}