4.3.1 Line breaking

Line breaks are normally determined automatically. They are chosen so that lines look neither cramped nor loose, and consecutive lines have similar density.

To manually force a line break at a bar line, use the \break command:

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

[image of music]

By default, breaks are only allowed at bar lines. There are also a few other factors that can prevent a break from being allowed at a certain bar line:

The \break command forces a break in all cases, regardless of the presence of a bar line or any other factor. It is also possible to bypass all these factors using the \allowBreak command. In the following example, breaks are allowed everywhere, even in the middle of a measure, and despite the presence of beams.

\repeat unfold 56 { c'8 \allowBreak }

[image of music]

If you find yourself using \allowBreak often, you may want to prevent some of the factors mentioned above from disabling breaks.

The \noBreak command will prevent a line break at the bar line where it is inserted.

Within a score, automatic line breaking is prevented within music lying between \autoLineBreaksOff and \autoLineBreaksOn commands. If automatic page breaks should also be prevented, the commands \autoBreaksOff and \autoBreaksOn should be used. Manual breaks are unaffected by these commands. Note that inhibiting automatic line breaks may cause music to run over the right margin if it cannot all be contained within one line.

Automatic line breaks (but not page breaks) may be enabled at single bar lines by using \once \autoLineBreaksOn at a bar line. This identifies a permitted rather than a forced line break.

The most basic settings influencing line spacing are indent and line-width. They are set in the \layout block. They control the indentation of the first line of music, and the lengths of the lines.

If ragged-right is set to #t in the \layout block, then systems end at their natural horizontal length, instead of being spread horizontally to fill the whole line. This is useful for short fragments, and for checking how tight the natural spacing is.

The option ragged-last is similar to ragged-right, but affects only the last line of the piece.

\layout {
  indent = 0\mm
  line-width = 150\mm
  ragged-last = ##t
}

For line breaks at regular intervals use \break separated by skips and repeated with \repeat. For example, this would cause the following 28 measures (assuming 4/4 time) to be broken every 4 measures, and only there:

<<
  \repeat unfold 7 {
    s1 \noBreak s1 \noBreak
    s1 \noBreak s1 \break
  }
  { the actual music… }
>>

Predefined commands

\break, \allowBreak, \noBreak, \autoBreaksOff, \autoBreaksOn, \autoLineBreaksOff, \autoLineBreaksOn.

Selected Snippets

Using an extra voice for breaks

Often it is easier to manage line and page-breaking information by keeping it separate from the music by introducing an extra voice containing only skips along with the \break, pageBreak and other layout information.

This pattern becomes especially helpful when overriding line-break-system-details and the other useful but long properties of NonMusicalPaperColumnGrob.

\paper { tagline = ##f }

music = \relative c'' { c4 c c c }

\score {
  \new Staff <<
    \new Voice {
      s1 * 2 \break
      s1 * 3 \break
      s1 * 6 \break
      s1 * 5 \break
    }
    \new Voice {
      \repeat unfold 2 { \music }
      \repeat unfold 3 { \music }
      \repeat unfold 6 { \music }
      \repeat unfold 5 { \music }
    }
  >>
}

[image of music]

See also

Notation Reference: \paper variables for line breaking The \layout block.

Snippets: Spacing.

Internals Reference: LineBreakEvent.

Known issues and warnings

Placing \autoLineBreaksOff or \autoBreaksOff before any music will cause error messages to appear. Always place these commands after some music.


LilyPond Notation Reference v2.25.22 (development-branch).