1.2.5 Bars


Bar lines

Bar lines are used to delimit measures and sections, and to indicate repetition. Normally, simple bar lines are automatically inserted into the printed output at places according to the current time signature. Various commands insert other kinds of bar lines automatically as part of their effect (see Automatic bar lines).

A bar line inserted automatically can be changed to another type with the \bar command:

\relative { e'4 d c2 \bar "!" }

[image of music]

The final note of a measure is not required to end on the automatically inserted bar line: the note is assumed to carry over into the next measure. But if a long sequence of such carry-over measures appears, the music can appear compressed or even flowing off the page. This is because automatic line breaks happen only at the end of complete measures, i.e., where all notes end before the end of a measure.

Note: An incorrect duration can inhibit line breaks, leading to a line of highly compressed music or music that flows off the page.

Line breaks are also permitted at manually inserted bar lines even within incomplete measures. To allow a line break without printing a bar line, use \allowBreak; see Line breaking.

This and other special bar lines may be inserted manually at any point. When they coincide with the end of a measure they replace the simple bar line which would have been inserted there automatically. When they do not coincide with the end of a measure the specified bar line is inserted at that point in the printed output.

Manual bar lines are purely visual. They do not affect any of the properties that a normal bar line would affect, such as measure numbers and accidentals. They do not affect the calculation and placement of subsequent automatic bar lines. When a manual bar line is placed where a normal bar line already exists, the effects of the original bar line are not altered.

Various single and double bar lines are available for manual insertion:

\relative {
  f'1 \bar "|"
  f1 \bar "."
  g1 \bar "||"     % see \section
  a1 \bar ".|"
  b1 \bar ".."
  c1 \bar "|.|"
  d1 \bar "|."     % see \fine
  e1
}

[image of music]

together with dotted and dashed bar lines:

\relative {
  f'1 \bar ";"
  g1 \bar "!"
  a1
}

[image of music]

and various repeat bar lines:

\relative {
  f'1 \bar ".|:"
  g1 \bar ":..:"
  a1 \bar ":|.|:"
  b1 \bar ":|.:"
  c1 \bar ":.|.:"
  d1 \bar "[|:"
  e1 \bar ":|][|:"
  f1 \bar ":|]"
  g1 \bar ":|."
  a1
}

[image of music]

Ticks and short bar lines are also available; however, in the context of Gregorian chant, using \divisioMinima and \divisioMaior is preferable (see Divisiones).

f'1 \bar "'"
g1 \bar ","
a1

[image of music]

LilyPond supports Kievan notation and provides a special Kievan bar line:

f'1 \bar "k"

[image of music]

Further details of this notation are explained in Typesetting Kievan square notation.

There are various in-staff segno signs which differ in their behavior at line breaks:

\fixed c' {
  c4 4 4 4
  \bar "S"
  d4 4 4 4 \break
  \bar "S"
  e4 4 4 4
  \bar "S-|"
  f4 4 4 4 \break
  \bar "S-|"
  g4 4 4 4
  \bar "S-||"
  a4 4 4 4 \break
  \bar "S-||"
  b4 4 4 4
  \bar "S-S"
  c'4 4 4 4 \break
  \bar "S-S"
  d'1
}

[image of music]

Although the bar line types signifying repeats may be inserted manually they do not in themselves cause LilyPond to recognize a repeated section. Such repeated sections are better entered using the various repeat commands (see Repeats), which automatically print the appropriate bar lines, which can be customized (see Automatic bar lines).

In addition, you can specify ".|:-||", which is equivalent to ".|:" except at line breaks, where it gives a double bar line at the end of the line and a start repeat at the beginning of the next line.

\fixed c' {
  c4 4 4 4
  \bar ".|:"
  d4 4 4 4 \break
  \bar ".|:"
  e4 4 4 4
  \bar ".|:-|"
  f4 4 4 4 \break
  \bar ".|:-|"
  g4 4 4 4
  \bar ".|:-||"
  a4 4 4 4 \break
  \bar ".|:-||"
  b4 4 4 4
  \bar ".|:-|."
  c'4 4 4 4 \break
  \bar ".|:-|."
  d'4 4 4 4
}

[image of music]

There are various combinations of repeats with the segno sign:

\fixed c' {
  g,4 4 4 4
  \bar ":|.S"
  a,4 4 4 4 \break
  \bar ":|.S"
  b,4 4 4 4
  \bar ":|.S-S"
  c4 4 4 4 \break
  \bar ":|.S-S"
  d4 4 4 4
  \bar "S.|:-S"
  e4 4 4 4 \break
  \bar "S.|:-S"
  f4 4 4 4
  \bar "S.|:"
  g4 4 4 4 \break
  \bar "S.|:"
  a4 4 4 4
  \bar "S.|:-|"
  b4 4 4 4 \break
  \bar "S.|:-|"
  c'4 4 4 4
  \bar "S.|:-||"
  d'4 4 4 4 \break
  \bar "S.|:-||"
  e'4 4 4 4
  \bar ":|.S.|:"
  f'4 4 4 4 \break
  \bar ":|.S.|:"
  g'4 4 4 4
  \bar ":|.S.|:-S"
  a'4 4 4 4 \break
  \bar ":|.S.|:-S"
  b'1
}

[image of music]

Many of the repeat and segno bar lines above can be inserted automatically by \repeat commands (see Repeats).

New bar line types can be defined with \defineBarLine:

\defineBarLine bartype #'(end begin span)

In addition to bartype (the character string that will then be used to refer to that new bar line), it takes three values: the first two determine the bar line’s appearance when it occurs at a line break, in which case the first and second given glyphs are printed respectively at the end of the system and at the beginning of the next one. The third given glyph is only relevant in multi-staff systems (see Grouping staves), where it is used as span bar, printed between staves.

The \defineBarLine arguments specifying replacement glyphs can be set to #t to copy the mid-line glyph or #f to create no bar line. The empty string, "", yields a zero-width bar line.

After the definiton, the new bar line can be used by \bar bartype.

There are several bar line elements, and there are predefined bar types that use most of them individually. Some elements are primarily intended to be combined with others; those do not have predefined individual bar types.

\defineBarLine ":" #'(#f #t #f)
\defineBarLine "=" #'(#t #f #t)
\defineBarLine "[" #'(#f #t #f)
\defineBarLine "]" #'(#t #f #f)

\new Staff {
  s1 \bar "'"
  s1 \bar ","
  s1 \bar "|"
  s1 \bar "."
  s1 \bar "!"
  s1 \bar ";"
  s1 \bar ":"
  s1 \bar "k"
  s1 \bar "S"
  s1 \bar "="
  s1 \bar "["
  s1 \bar "]"
  s1 \bar ""
}

[image of music]

The "=" bar line provides a double span bar line for use in combination with the segno sign. Using it as a stand-alone double thin bar line is not recommended; \bar "||" is preferred.

The "-" sign starts annotations to bar lines which are useful to distinguish those with identical appearance but different behavior at line breaks and/or different span bars. The part following the "-" sign is not used for building up the bar line.

\defineBarLine "||-dashedSpan" #'(#t #f "!!")

\new StaffGroup <<
  \new Staff \relative c'' {
    c1 \bar "||"
    c1 \bar "||-dashedSpan"
    c1
  }
  \new Staff \relative c'' {
    c1
    c1
    c1
  }
>>

[image of music]

Furthermore, the space character " " serves as a placeholder for defining span bars correctly aligned to the main bar lines:

\defineBarLine ":|.-wrong" #'(#t #f "|.")
\defineBarLine ":|.-right" #'(#t #f " |.")

\new StaffGroup <<
  \new Staff \relative c'' {
    c1 \bar ":|.-wrong"
    c1 \bar ":|.-right"
    c1
  }
  \new Staff \relative c'' {
    c1
    c1
    c1
  }
>>

[image of music]

New bar line types defined using \defineBarLine may even, in turn, be used in a second bar line definition. Such ‘nested’ definitions make it possible to use customized glyphs in places where it would not be otherwise possible, such as system ends:

\defineBarLine "||-dashEverywhere" #'("!!" "!!" "!!")
\defineBarLine "||-advancedDashSpan" #'("||-dashEverywhere" #f "!!")

\new StaffGroup <<
  \new Staff \relative c'' {
    c1 \bar "||"
    c1 \bar "||-advancedDashSpan"
    c1 \bar "||-advancedDashSpan"
  }
  \new Staff \relative c'' {
    c1
    c1
    c1
  }
>>

[image of music]

If additional elements are needed, LilyPond provides a simple way to define them. For more information on modifying or adding bar lines, see file ‘scm/bar-line.scm’.

In scores with many staves, a \bar command in one staff is automatically applied to all staves. The resulting bar lines are connected between different staves of a StaffGroup, PianoStaff, or GrandStaff.

<<
  \new StaffGroup <<
    \new Staff \relative {
      e'4 d
      \bar "||"
      f4 e
    }
    \new Staff \relative { \clef bass c'4 g e g }
  >>
  \new Staff \relative { \clef bass c'2 c2 }
>>

[image of music]

The bar type used for automatically inserted measure bar lines is "|". This may be changed at any time with ‘\set Timing.measureBarType = bartype’.

See also

Notation Reference: Line breaking, Repeats, Grouping staves.

Installed Files: ‘scm/bar-line.scm’.

Snippets: Rhythms.

Internals Reference: BarLine (created at Staff level), SpanBar (across staves), Timing_translator (for Timing properties).


Automatic bar lines

Various commands other than \bar can also create bar lines as part of their effect. The bar lines created in these cases can be changed by setting context properties. If a property is set to '() or is unset, it is ignored; otherwise, the value must be a predefined bar type or one previously defined with the \defineBarLine command (see Bar lines).

Multiple reasons for creating different automatic bar lines may apply at the same time. Conflicts are resolved in part by providing properties for predetermined combinations and in part by a priority scheme. The table below presents the available properties in order of increasing priority.

underlyingRepeatBarType

Used at points of repetition or departure where no bar line would otherwise appear. This is expected when repeated sections are not aligned to measures. Several commands employ this bar type: \codaMark, \inStaffSegno, \repeat segno, \repeat volta, and \segnoMark.

caesuraType underlying-bar-line

Used at \caesura; see Phrase bar lines in hymn tunes.

measureBarType

Used at a measure boundary.

caesuraType bar-line

Used at \caesura; see Phrase bar lines in hymn tunes.

sectionBarType

Used at a section break created by \section.

fineBarType

Used at \fine.

doubleRepeatBarType
doubleRepeatSegnoBarType
endRepeatBarType
endRepeatSegnoBarType
fineSegnoBarType
fineStartRepeatSegnoBarType
segnoBarType
startRepeatBarType
startRepeatSegnoBarType

Only one of these bar types is used at a time; which one is used depends on the structure of the piece.

Properties with startRepeat or endRepeat in the name are used at the start or end of a repeated section created by \repeat volta, and properties with doubleRepeat in the name are used where the end of one repeated section and the start of another coincide.

Properties with segno in the name are used at an in-staff segno, which can be created by \repeat segno or \segnoMark when the segnoStyle property is set to bar-line, or created by \inStaffSegno.

Properties with fine in the name are used at \fine.

Priority applies independently to beginning-, middle-, and end-of-line bar lines, allowing a lower-priority bar line to appear where higher-priority bar types have no glyphs defined (see Bar lines).

\fixed c' {
  c1 \section \break
  \repeat volta 2 d1
}

[image of music]

Selected Snippets

Setting the double repeat default for volte

There are three different styles of double repeats for volte, that can be set using doubleRepeatBarType.

\relative c'' {
  \repeat volta 2 { c1 }
  \set Score.doubleRepeatBarType = #":..:"
  \repeat volta 2 { c1 }
  \set Score.doubleRepeatBarType = #":|.|:"
  \repeat volta 2 { c1 }
  \set Score.doubleRepeatBarType = #":|.:"
  \repeat volta 2 { c1 }
}

[image of music]

See also

Notation Reference: Bar lines, Repeats.

Snippets: Rhythms.

Internals Reference: Repeat_acknowledge_engraver.


Bar numbers

Bar numbers are typeset by default at the start of every line except the first line. The number itself is stored in the currentBarNumber property, which is normally updated automatically for every measure. It may also be set manually:

\relative c' {
  c1 c c c
  \break
  \set Score.currentBarNumber = #50
  c1 c c c
}

[image of music]

The default behavior of only printing bar numbers at the start of every line can be changed through the break-visibility property of BarNumber. This takes three values which may be set to #t or #f to specify whether the corresponding bar number is visible or not. The order of the three values is end of line visible, middle of line visible, beginning of line visible. In the following example bar numbers are printed at all possible places:

\relative c' {
  \override Score.BarNumber.break-visibility = ##(#t #t #t)
  \set Score.currentBarNumber = #11
  c1 | c | c | c |
  \break
  c1 | c | c | c |
}

[image of music]

Selected Snippets

Printing the bar number for the first measure

By default, the first bar number in a score is suppressed if it is less than or equal to 1. By setting barNumberVisibility to all-bar-numbers-visible, any bar number can be printed for the first measure and all subsequent measures.

\layout {
  indent = 0
  ragged-right = ##t
}

\relative c' {
  \set Score.barNumberVisibility = #all-bar-numbers-visible
  c1 | d | e | f \break
  g1 | e | d | c
}

[image of music]

Printing bar numbers at regular intervals

By setting the barNumberVisibility property, bar numbers can be printed at regular intervals. Here the bar numbers are printed every two measures except at the end of the line.

\relative c' {
  \override Score.BarNumber.break-visibility = #end-of-line-invisible
  \set Score.currentBarNumber = #11
  % Print a bar number every second measure
  \set Score.barNumberVisibility = #(every-nth-bar-number-visible 2)
  c1 | c | c | c | c
  \break
  c1 | c | c | c | c
}

[image of music]

Printing bar numbers with changing regular intervals

Using the set-bar-number-visibility context function, bar number intervals can be changed.

\relative c' {
  \override Score.BarNumber.break-visibility = #end-of-line-invisible
  \context Score \applyContext #(set-bar-number-visibility 4)
  \repeat unfold 10 c'1
  \context Score \applyContext #(set-bar-number-visibility 2)
  \repeat unfold 10 c
}

[image of music]

Printing bar numbers for broken measures

By default a BarNumber of a broken measure is not repeated at the beginning of the new line. Use first-bar-number-invisible-save-broken-bars for barNumberVisibility to get a parenthesized BarNumber there.

\layout {
  \context {
    \Score
    barNumberVisibility = #first-bar-number-invisible-save-broken-bars
    \override BarNumber.break-visibility = ##(#f #t #t)
  }
}

\relative c' {
  c1 | d | e | f2 \bar "" \break
  fis | g1 | e2 \bar "" \break
  <>^"reenabled default"
  % back to default -
  % \unset Score.barNumberVisibility would do so as well
  \set Score.barNumberVisibility =
    #first-bar-number-invisible-and-no-parenthesized-bar-numbers
  es | d1 | c
}

[image of music]

Printing bar numbers using modulo-bar-number-visible

If the remainder of the division of the current BarNumber by the first argument of modulo-bar-number-visible equals its second argument print the BarNumber.

Useful to print the BarNumber at certain distances, p.e:

\layout {
  \context {
    \Score
    \override BarNumber.break-visibility = ##(#f #t #t)
    barNumberVisibility = #(modulo-bar-number-visible 3 2)
  }
}

\relative c' {
  c1 | d | e | f \break
  g1 | e | d | c
}

[image of music]

Printing bar numbers inside boxes or circles

Bar numbers can also be printed inside boxes or circles.

\relative c' {
  % Prevent bar numbers at the end of a line and permit them elsewhere
  \override Score.BarNumber.break-visibility = #end-of-line-invisible
  \set Score.barNumberVisibility = #(every-nth-bar-number-visible 4)

  % Increase the size of the bar number by 2
  \override Score.BarNumber.font-size = #2

  % Draw a box round the following bar number(s)
  \override Score.BarNumber.stencil
    = #(make-stencil-boxer 0.1 0.25 ly:text-interface::print)
  \repeat unfold 5 { c1 }

  % Draw a circle round the following bar number(s)
  \override Score.BarNumber.stencil
    = #(make-stencil-circler 0.1 0.25 ly:text-interface::print)
  \repeat unfold 4 { c1 } \bar "|."
}

[image of music]

Alternative bar numbering

Two alternative methods for bar numbering can be set, especially for when using repeated music.

\relative c'{
  \set Score.alternativeNumberingStyle = #'numbers
  \repeat volta 3 { c4 d e f | }
    \alternative {
      { c4 d e f | c2 d \break }
      { f4 g a b | f4 g a b | f2 a | \break }
      { c4 d e f | c2 d }
    }
  c1 \break
  \set Score.alternativeNumberingStyle = #'numbers-with-letters
  \repeat volta 3 { c,4 d e f | }
    \alternative {
      { c4 d e f | c2 d \break }
      { f4 g a b | f4 g a b | f2 a | \break }
      { c4 d e f | c2 d }
    }
  c1
}

[image of music]

Aligning bar numbers

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.

\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
  % Center-align bar numbers
  \override Score.BarNumber.self-alignment-X = #CENTER
  c1 | c1
  % Left-align bar numbers
  \override Score.BarNumber.self-alignment-X = #LEFT
  c1 | c1
}

[image of music]

Removing bar numbers from a score

Bar numbers can be removed entirely by removing the Bar_number_engraver from the Score context.

\layout {
  \context {
    \Score
    \omit BarNumber
    % or:
    %\remove "Bar_number_engraver"
  }
}

\relative c'' {
  c4 c c c \break
  c4 c c c
}

[image of music]

Measure-centered bar numbers

For film scores, a common convention is to center bar numbers within their measure. This is achieved through setting the centerBarNumbers context property to true. When this is used, the type of the bar number grobs is CenteredBarNumber rather than BarNumber.

This example demonstrates a number of settings: the centered bar numbers are boxed and placed below the staves.

\layout {
  \context {
    \Score
    centerBarNumbers = ##t
    barNumberVisibility = #all-bar-numbers-visible
    \override CenteredBarNumber.stencil
      = #(make-stencil-boxer 0.1 0.25 ly:text-interface::print)
    \override CenteredBarNumberLineSpanner.direction = #DOWN
  }
}

\new StaffGroup <<
  \new Staff \relative c' {
    d4-. f8( e d4) bes'-> |
    d,-. f8( e d4) cis'-> |
    g-. f8( d e4) g-> |
    a,1-> |
  }
  \new Staff \relative c {
    \clef bass
    d4 f8 e d2~ |
    4 f8 e d2~ |
    4 4 2 |
    a1 |
  }
>>

[image of music]

See also

Snippets: Rhythms.

Internals Reference: BarNumber, CenteredBarNumber, CenteredBarNumberLineSpanner, Bar_number_engraver, Centered_bar_number_align_engraver.

Known issues and warnings

Bar numbers may collide with the top of the StaffGroup bracket, if there is one. To solve this, the padding property of BarNumber can be used to position the number correctly. See StaffGroup and BarNumber for more.


Bar and bar number checks

Bar checks help detect errors in the entered durations. A bar check may be entered using the bar symbol, |, at any place where a bar line is expected to fall. If bar check lines are encountered at other places, a list of warnings is printed in the log file, showing the line numbers and lines in which the bar checks failed. In the next example, the second bar check will signal an error.

\time 3/4 c2 e4 | g2 |

An incorrect duration can result in a completely garbled score, especially if the score is polyphonic, so a good place to start correcting input is by scanning for failed bar checks and incorrect durations.

If successive bar checks are off by the same musical interval, only the first warning message is displayed. This allows the warning to focus on the source of the timing error.

Bar checks can also be inserted in lyrics:

\lyricmode {
  \time 2/4
  Twin -- kle | Twin -- kle |
}

Note that bar check marks in lyrics are evaluated at the musical moment when the syllable following the check mark is processed. If the lyrics are associated with the notes of a voice which has a rest at the beginning of a bar, then no syllable can be located at the start of that bar and a warning will be issued if a bar check mark is placed in the lyrics at that position.

It is also possible to redefine the action taken when a bar check or pipe symbol, |, is encountered in the input, so that it does something other than a bar check. This is done by assigning a music expression to "|". In the following example | is set to insert a double bar line wherever it appears in the input, rather than checking for end of bar.

"|" = \bar "||"
{
  c'2 c' |
  c'2 c'
  c'2 | c'
  c'2 c'
}

[image of music]

When copying large pieces of music, it can be helpful to check that the LilyPond bar number corresponds to the original that you are entering from. This can be checked with \barNumberCheck, for example,

\barNumberCheck #123

will print a warning if the currentBarNumber is not 123 when it is processed.

See also

Snippets: Rhythms.


Rehearsal marks

To print a rehearsal mark, use the \mark command.

\relative c'' {
  c1 \mark \default
  c1 \mark \default
  c1 \mark \default
  c1 \mark \default
}

[image of music]

The mark is incremented automatically if you use \mark \default, but you can also use an integer argument to set the mark manually. The value to use is stored in the property rehearsalMark.

\relative c'' {
  c1 \mark \default
  c1 \mark \default
  c1 \mark #8
  c1 \mark \default
  c1 \mark \default
}

[image of music]

The letter ‘I’ is skipped in accordance with engraving traditions. If you wish to include the letter ‘I’, then use one of the following commands, depending on which style of rehearsal mark you want (letters only, letters in a hollow box, or letters in a hollow circle).

\set Score.rehearsalMarkFormatter = #format-mark-alphabet
\set Score.rehearsalMarkFormatter = #format-mark-box-alphabet
\set Score.rehearsalMarkFormatter = #format-mark-circle-alphabet
\relative c'' {
  \set Score.rehearsalMarkFormatter = #format-mark-box-alphabet
  c1 \mark \default
  c1 \mark \default
  c1 \mark #8
  c1 \mark \default
  c1 \mark \default
}

[image of music]

The style is defined by the property rehearsalMarkFormatter. It is a function taking the current mark (an integer) and the current context as argument. It should return a markup object. In the following example, rehearsalMarkFormatter is set to a predefined procedure. After a few measures, it is set to a procedure that produces a boxed number.

\relative c'' {
  \set Score.rehearsalMarkFormatter = #format-mark-numbers
  c1 \mark \default
  c1 \mark \default
  \set Score.rehearsalMarkFormatter = #format-mark-box-numbers
  c1 \mark \default
  \set Score.rehearsalMarkFormatter = #format-mark-circle-numbers
  c1 \mark \default
  \set Score.rehearsalMarkFormatter = #format-mark-circle-letters
  c1
}

[image of music]

The file ‘scm/translation-functions.scm’ contains the definitions of format-mark-letters (the default format), format-mark-box-letters, format-mark-numbers, and format-mark-box-numbers. These can be used as inspiration for other formatting functions.

You may use format-mark-barnumbers, format-mark-box-barnumbers, and format-mark-circle-barnumbers to get bar numbers instead of incremented numbers or letters.

For common tweaks to the positioning of rehearsal marks, see Formatting text. For more precise control, consider break-alignable-interface (see Aligning objects).

The file ‘scm/translation-functions.scm’ contains the definitions of format-mark-numbers and format-mark-letters. They can be used as inspiration for other formatting functions.

Selected Snippets

Printing marks on every staff

Although marks are normally only printed above the topmost staff, they may also be printed on every staff.

\score {
  <<
    \new Staff { \mark \default c''1 \textMark "molto" c'' }
    \new Staff { \mark \default c'1 \textMark "molto" c' }
  >>
  \layout {
    \context {
      \Score
      \remove Mark_engraver
      \remove Text_mark_engraver
      \remove Staff_collecting_engraver
    }
    \context {
      \Staff
      \consists Mark_engraver
      \consists Text_mark_engraver
      \consists Staff_collecting_engraver
    }
  }
}

[image of music]

See also

Notation Reference: The Emmentaler font, Formatting text, Aligning objects, Music notation inside markup, Metronome marks, Section labels.

Installed Files: ‘scm/translation-functions.scm’.

Snippets: Rhythms.

Internals Reference: AdHocMarkEvent, RehearsalMark, RehearsalMarkEvent.


Measure counts

Measure counts are a way to number consecutive measures, for example as an aid for musicians to count measures in written-out repeats. Using this feature requires adding the Measure_counter_engraver to a context type, usually Staff or Score.

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

\relative c' {
  \time 6/8
  \key e \minor
  r4 a8 b c dis
  \startMeasureCount
  \repeat unfold 3 {
    e8 b e g8. fis32 e dis8
  }
  \stopMeasureCount
  b'4. r
}

[image of music]

Broken measures are numbered in parentheses.

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

\relative c' {
  \time 6/8
  \key e \minor
  r4 a8 b c dis
  \startMeasureCount
  e8 b e g8. fis32 e dis8
  e8 b e \break g8. fis32 e dis8
  e8 b e g8. fis32 e dis8
  \stopMeasureCount
  b'4. r
}

[image of music]

Compressed multi-measure rests receive special treatment: the full measure range is shown.

\layout {
  \context {
    \Staff
    \consists Measure_counter_engraver
  }
  \context {
    \Voice
    \override MultiMeasureRestNumber.direction = #DOWN
  }
}

\compressMMRests {
  \key e \minor
  \startMeasureCount
  \new CueVoice {
    b4.( e'8) b8 r e' r
  }
  R1*2
  \stopMeasureCount
  g'2\> fis'2\!
}

[image of music]

Measure counters honor alternative numbering styles. If the style is numbers-with-letters, they render best with a textual font.

\layout {
  \context {
    \Score
    alternativeNumberingStyle = #'numbers-with-letters
  }
  \context {
    \Staff
    \consists Measure_counter_engraver
    \override MeasureCounter.Y-offset = 6
    \override MeasureCounter.font-encoding = #'latin1
    \override MeasureCounter.font-size = 1
  }
}

\relative c' {
  \startMeasureCount
  \repeat volta 2 {
    c8 d e f c d e f
  }
  \alternative {
    { e4 d c b }
    { g'4 g c2 }
  }
  \bar "|."
  \stopMeasureCount
}

[image of music]

Predefined commands

\startMeasureCount, \stopMeasureCount.

See also

Notation Reference: Modifying context plug-ins, Compressing empty measures, Breaks, Bar numbers.

Internals Reference: Measure_counter_engraver, MeasureCounter, measure-counter-interface.


Section divisions

The \section command marks a point where one section of music ends and another begins. It does not have to be followed by more music: it may also be used to emphasize that the written end of the music is not the end of the piece, such as at a D.C. instruction or where one movement continues into the next without a break. \section normally creates a double bar line, but its effect can depend on other notation, e.g., repeat bar lines.

The \fine command ends the piece, normally with a final bar line. It is not limited to use at the written end of the music: it may also appear inside \repeat (see Al-fine repeats).

A section can optionally be named with \sectionLabel (see Section labels).

\fixed c' {
  f1
  \section
  \sectionLabel "Refrain"
  g1
  a1
  \fine
}

[image of music]

For details on interactions of \fine and \section bar lines with other types of bar lines, and options for changing their appearance, see Automatic bar lines.

See also

Music Glossary: fine.

Notation Reference: Automatic bar lines, Divisiones, Al-fine repeats, Section labels.

Internals Reference: FineEvent, SectionEvent.


LilyPond — Notation Reference v2.24.4 (stable-branch).