# How do I get the bar lines in successive staves to align?

In the following, lines 2-6 have the same notes, yet the bar lines in the middle are not aligned. Is there a way to get them to align? Also, is there a way to extend the bar lines to the lyrics (here generated automatically using NoteNames context)

        \version "2.18.2"

musicA = {c d e f g a b c c b a g f e d c
c d e f c d e f c d e f g a b c
c b a g c b a g c b a g f e d c}
fooBar = { s1 \bar "!" s2 \bar "!" s2 \bar "||" }

\score {
\new Staff
{

\compoundMeter #'((4 4) (2 4) (2 4))
\set Timing.beatStructure = #'(4 2 2 )
<<
\new Voice
{

}
\context NoteNames  {
\musicA }

\new Voice = "theBarLines" { \repeat unfold 6 {\repeat unfold 2 \fooBar \bar "|." }}
\new Voice = "breaks" {\repeat unfold 5 {s2*8 \break}}

>>
}}

• Aligning bar lines is not a good idea. It’s too easy to skip a line when they are. Sep 13, 2014 at 21:01
• Definitely agreed, unaligned staves is a feature not a bug. Good engraving practice is to force at least a slight misalignment, even when the two lines are identical. Oct 21, 2014 at 1:15
• This is not true in all contexts. For example, in jazz lead sheets it's very common practice to deliberately align bars vertically, especially for the majority of tunes which are constructed in multiples of 4 or 8 bars. For example a typical 32-bar AABA structure would have 2 lines of 4 bars for each section, and it's easier to read and learn the tune when it's laid out in this more regular geometric fashion. Mar 16, 2017 at 11:21

I agree with the comment from Édouard. Of course, one can tell LilyPond to leave all optical corrections that are put in for a more even optical appearance of the music flow (like kernings are in a font). Your question is like asking how to tell your typesetter to have "rivers" in your text line up better.

LilyPond is flexible: you can tell it to stop doing what it is good at.

\version "2.18.2"

musicA = {c d e f g a b c c b a g f e d c
c d e f c d e f c d e f g a b c
c b a g c b a g c b a g f e d c}
fooBar = { s1 \bar "!" s2 \bar "!" s2 \bar "||" }

\score {
\new Staff
{

\compoundMeter #'((4 4) (2 4) (2 4))
\set Timing.beatStructure = #'(4 2 2 )
<<
\new Voice
{
}
\context NoteNames  { \musicA }
\new Voice = "theBarLines" { \repeat unfold 6 {\repeat unfold 2 \fooBar \bar "|." }}
\new Voice = "breaks" {\repeat unfold 5 {s2*8 \break}}
>>
}
\layout {
\context {
\Score
proportionalNotationDuration = #(ly:make-moment 1/4)
\override NoteSpacing.stem-spacing-correction = #0
\override NoteSpacing.same-direction-correction = #0
\override NoteSpacing.knee-spacing-correction = #0
}}
}