Jump to content

Making lyrics take bar lines into account

From LilyPond wiki
Revision as of 22:47, 28 January 2026 by Gabriel Ellsworth (talk | contribs) (Created page with "By default, Lyrics contexts do not contain <code>Bar_engraver</code>, so your lyrics will not take into account divisions between measures. Longer lyric items will appear to “spill across” bar lines. This snippet shows how you can add <code>Bar_engraver</code> to lyrics and hide bar lines, so that each individual lyric will be contained within the horizontal space between two consecutive bar lines. This approach can have undesirable effects on the horizontal spacin...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

By default, Lyrics contexts do not contain Bar_engraver, so your lyrics will not take into account divisions between measures. Longer lyric items will appear to “spill across” bar lines.

This snippet shows how you can add Bar_engraver to lyrics and hide bar lines, so that each individual lyric will be contained within the horizontal space between two consecutive bar lines.

This approach can have undesirable effects on the horizontal spacing between bar lines and note heads. You may want to combine it with some \tweak self-alignment-X commands placed before your longer lyric items.

\version "2.24"

%%% Approach suggested by Kieren MacMillan in
%% https://lists.gnu.org/archive/html/lilypond-user/2025-07/msg00016.html

\header {
  title = \markup { Hymn: \italic { Of the Father’s love begotten } }
  subtitle = "Stanza 3"
}

music = \relative c' {
  \key ees \major \time 3/4
  es2 f4 | g2 as4 | g2 f4 | g2( f4) | es2. | 
  g2 as4 | bes2 c4 | bes4( g4) as4 | bes2. | 
  c2 d4 | es2 bes4 | bes2 as4 | g2( f4) | es2. | 
  c2 d4 | es2 f4 | es4( c4) d4 | es2. | 
  es2 f4 | g2 as4 | g2 f4 | bes2( c4 | bes4 g4 as4) | bes2. | 
  es,2 d4 | c2 d4 | es2 c4 | bes2. | 
  es2 f4 | g2 bes4 | g2 es4 | f2.( | es2.) \fine
}

stanza = \lyricmode {
  \set stanza = "3. "
  Let the heights of heaven a -- dore him; 
  an -- gel hosts, his prai -- ses sing; 
  powers, do -- min -- ions, bow be -- fore him, 
  and ex -- tol our God and King; 
  let no tongue on earth be si -- lent, 
  ev -- ery voice in con -- cert ring, 
  e -- ver -- more and e -- ver -- more! __
}

%%  Top-level layout (applying to all scores)
\layout {
  indent = 0
  \context {
    \Voice
    \consists "Melody_engraver"
  }
  \context {
    \Staff
    \omit TimeSignature
  }
}

\markup \bold { \circle 1 LilyPond’s default behaviour: }
\score {
  <<
  \new Voice = "congregation" \music
  \new Lyrics \lyricsto "congregation" \stanza
  >>
}

\markup \bold { \circle 2 with Bar_engraver added to the Lyrics context: }
\score {
  <<
  \new Voice = "congregation" \music
  \new Lyrics \lyricsto "congregation" \stanza
  >>
  \layout {
    \context {
      \Lyrics
      \consists "Bar_engraver"
      \hide BarLine
    }
  }
}

beginningMusic = \relative c' {
  \key ees \major \time 3/4
  es2 f4 | g2 as4 | g2 f4 | g2( f4) | es2. | 
}

beginningStanza = \lyricmode {
  \set stanza = "3. "
  Let the 
  \tweak self-alignment-X #-0.4 heights of 
  \tweak self-alignment-X #-0.5 heaven 
  a -- dore him; 
}

\markup \bold { \circle 3 with Bar_engraver \underline and horizontal alignment tweaks: }
\score {
  <<
  \new Voice = "congregation" \beginningMusic
  \new Lyrics \lyricsto "congregation" \beginningStanza
  >>
  \layout {
    \context {
      \Lyrics
      \consists "Bar_engraver"
      \hide BarLine
    }
  }
}