Aligning bar numbers: Difference between revisions

m New category
Fix code and description for version 2.24 .
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
Bar numbers by default are right-aligned to their parent object. This is usually the left edge of a line or, if numbers are printed within a line, the left hand side of a bar line. The numbers may also be positioned directly over the bar line or left-aligned to the bar line.
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 <code>break-alignment-list</code>, 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).


<lilypond version="2.24">
<lilypond version="2.24">
Line 9: Line 9:
   % Print a bar number every second measure
   % Print a bar number every second measure
   \set Score.barNumberVisibility = #(every-nth-bar-number-visible 2)
   \set Score.barNumberVisibility = #(every-nth-bar-number-visible 2)
   c1 | c1
 
   % Center-align bar numbers
   c1 | c1 | c1 | \break
   \override Score.BarNumber.self-alignment-X = #CENTER
  c1 | c1 | c1 | \break
   c1 | c1
    
   % Left-align bar numbers
   \override Score.BarNumber.self-alignment-X =
   \override Score.BarNumber.self-alignment-X = #LEFT
    #(break-alignment-list CENTER RIGHT CENTER)
  c1 | c1
   c1 | c1 | c1 | \break
   c1 | c1 | c1 |
}
 
\paper {
   line-width = 70\mm
}
}
</lilypond>
</lilypond>