2.1.1 Bar lines and bar checks

Bar lines

Single bar lines are automatically placed in the music so there is no need to add them manually. Other types of bar lines are added using \bar, for example \bar "||" for a double bar line, or \bar "|." for an ending bar line. For a full list of bar lines see the Bar lines.

\relative { g'1 e1 \bar "||" c2. c'4 \bar "|." }

[image of music]

Bar checks

Though not strictly necessary, bar checks should be used in the input code to show where bar lines are expected to fall. They are entered using the bar symbol, |. With bar checks, the program can verify that you’ve entered durations that make each measure add up to the correct length. Bar checks also make your input code easier to read, since they help to keep things organized.

\relative {
  g'1 | e1 | c2. c' | g4 c g e | c4 r r2 |

[image of music]

If you compile the code in the example above, you should see a warning in the console output:

warning: barcheck failed at: 1/2
 g'1 | e1 | c2. c'
                   | g4 c g e | c4 r r2 |

Although the missing duration is clear in the musical output in this simple example, the warning in the console output is far more effective in drawing attention to the missing 4 in bar 3.

See also

Notation Reference: Bar and bar number checks.

LilyPond — Learning Manual v2.23.4 (development-branch).