10

Using LilyPond, I'm engraving some music that consists of two parts that are repeated. The first repeated phrase contains an alternate ending. By default, LilyPond renders the MWE below:

\version "2.16.2"

\score {
\new Staff \relative c'' {
    \repeat volta 2 {
        a1 | a
    }
    \alternative{
        { b }
        { a }
    }

    \break

    \repeat volta 2 {
        c1 | c | c | c
    }
}
\layout {}
}

like this:

MWE rendered with LilyPond

This looks alright, except that I would like the second ending to have a double bar line ("||") after it. However, tweaking the MWE above in such a way that one would expect that to happen (\bar "||"\break\bar "|:") results in the same output. Removing the second bar and only putting the double bar before (or after) the break (eg. \bar "||"\break) results in:

Rendering of the tweaked MWE illustrating the problem

LilyPond doesn't seem to understand that it actually makes sense to have both bars (since I've manually inserted a break between the two measures).

Is there a way to force the bar engraver to output both bars?

3 Answers 3

7

Just after posting, I found the answer to my own question in the Lilypond Documentation. For version 2.16 (which I'm using):

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.

so one would write:

\break\bar "||:"

For version 2.17 (unstable / development) it is currently:

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.

eg:

\break\bar ".|:-||"
2
  • It's so weird that ".|:-||" is the new way! To write "||:" or even ".||:" is more logical to my mind. Jul 2, 2017 at 15:04
  • I'm downvoting this only because it's obsolete. In newer versions you can use \section as mentioned in the other answer.
    – benrg
    May 20, 2023 at 23:14
3

LilyPond v2.23 offers a few new commands: The \section command provides an elegant solution for printing double bar lines — and it works straight-out-of-the-box when adjacent to repeat barlines.

\section\break

see: 1.2.5 Bars - Automatic bar lines

0

What worked for me is putting \bar ":|." \break at the end of the first repeated section. Then when there should be starting repeat dots, I put

\hideNotes \grace{a32} \unHideNotes \bar ".|:"

I guess Lilypond internally wants SOMETHING between the two bar lines to make things work. Apparently a \break isn't good enough, but a grace note is.

I'm using Lilypond 2.24.1

4
  • If you post this as a separate question, with enough code to demonstrate the \section command not working correctly, you’ll probably get an answer. Jan 22 at 11:24
  • I posted this as a possible solution for the problem described by @user5952. I'm not sure why you two thought I was asking a question.
    – Frotz
    Jan 23 at 7:44
  • You shouldn’t need to use an invisible grace note for this, so I imagine something else has gone wrong. Jan 23 at 11:36
  • 1
    @ElementsInSpace clearly that's so. I've posted a new question asking about why Lilypond behaves like it does and what a better solution might be.
    – Frotz
    Jan 23 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.