This is a repeat of Rendering second ending closing bar when followed by another repeat in LilyPond because I too had this problem and couldn't make any of the suggestions work. I offered my work-around, but this was interpreted as a question and suggested to me that I ask a new question.

A post answer caveat: What I'm trying to render is not considered good practice. However it is common in music for bagpipes. If you're graving your own music, even if it's for a bagpipe, please don't do your voltas like this.

So here's my specific problem:

For this code:

\version "2.24.1"

\layout {
  indent = 0.0\in
  \context {
    \Score \remove Bar_number_engraver

\score {
  \new Staff \relative c' {
    \time 4/4

    \repeat volta 2 {
      \bar ".|:"
      c4 c c c
      c c c c
      c c c c
      c c c

      \alternative {
        \volta 1 {
        \volta 2 {
          e4 \break
    \repeat volta 2 {
      a4 a a a
      a a a a
      a a a a
      a a a a

I get this:

dot trouble

The ending dots in the first section need to be put at the end of the line, not at the end of the first volta. I'm transcribing something that's written this way. I can erase those ending dots by appending\bar "" to the first volta. Then I tried to put \bar ":|." before the \break in the second volta. This was the result:

more dot trouble

See how the leading dots on the second section disappeared? If I put \bar ".|:" at the beginning of the second section, that set of dots appears, but now I have no bar at all at the end of the first section.

even more dot trouble

To make Lilypond do what I wanted it to do, I added \hideNotes \grace{a32} \unHideNotes before \bar ".|:" at the beginning of the section section. This is what I posted to the previous question as what worked for me. To repeat, I guess Lilypond wants something between the two logical barlines to make things work, but a \break isn't good enough.

good dots

One comment to my solution was that I shouldn't need to use an invisible grace note like this. I agree, but I see no other way to force Lilypond to do this and the other answers offered at the previous question don't work for me. Why does Lilypond behave like this? What is the correct way to get the repeat dots where I want them?

  • "The ending dots in the first section need to be put at the end of the line, not at the end of the first volta." Absolutely not. Assuming that you are only repeating twice, the repetition is only for the first time, so the dots must be right after the D note. Showing ending dots for the second ending is not only very confusing, but just wrong (it doesn't repeat anything, and bar length is wrong). In reality, the first is the only acceptable case of those you posted. I understand you want a double bar line at the end of the second ending, but all your other attempts are not valid solutions. Jan 24 at 1:50
  • Note that the repetition count is not the fundamental issue here, as the above would be wrong even for more than 2 repetitions: what should the musician play the third time? If what you're trying to achieve (as per your last image) is in the source material of what you're transcribing, you should not try to reproduce it, because it's just wrong notation, and almost any properly trained musician will raise their eyebrows and possibly ask for clarifications. The repetition dots can and must only be right after the last note/rest of a section that actually repeats. Jan 24 at 2:07
  • This is a sort of uncommon notation we’d occasionally find for alternates in the middle of a repeat. In this case it is only confusing. Notation has sort of quasi defaults for these things, and the advantage of using these is that people are used to them. Lilypond will by default try to keep to these conventions. You can tell it not to — Elements has given you a good explanation of how barlines work. But really you should ask yourself if you really want to disregard conventions, and if the benefits you get from it are worth the confusion you will get for it.
    – Lazy
    Jan 24 at 8:40
  • To repeat what I wrote below, this usage appeared in a published book of bagpipe tunes from a well-regarded piper. Pipe music is full of weirdness like this. I removed \include "bagpipe.ly" to keep my sample code as simple as I could make it.
    – Frotz
    Jan 24 at 21:15

1 Answer 1


Firstly, what you’re trying to achieve (the last image in your question) is a bit odd. The fourth measure looks like it has too many notes in it. And, placing the repeat dots after the 2nd ending is confusing because the repeat is supposed to happen at the end of the 1st time through, (not after the 2nd time through as suggested). But, I do understand that you are just trying to transcribe somebody else's notation (and what it means is clear).

LilyPond is expecting that measure to finish after the 1st ending, which is why you have to erase the automatic repeat barline with \bar "", (a dashed barline \bar "!" might look a lot nicer).

It’s also expecting the 2nd ending to be the start of a new measure. I can see that you’ve removed the measure numbers for some reason, but if you did want to show them correctly (and assuming that you’re counting both the endings as part of the same measure) you can set the measure number with \set Score.currentBarNumber = #4 inside the \volta 2 block.

LilyPond is a bit weird with barlines that coincide with line breaks. This is because technically, barlines are drawn differently depending on whether they’re at the end, middle, or start of a line, and a barline at the end of one line will sometimes affect a barline at the start of a new line. Your attempts (\bar ":|." and \bar ".|:") are only setting the barline for one side of the line break. To tell LilyPond that you want to force a barline with repeat dots to appear on both sides you can use \bar ":..:" (or \bar ":|.|:" if you prefer — you can see the difference between these when this doesn’t coincide with a line break).

For documentation about manual barlines see:

  • 1. "and what it means is clear": it becomes "clear" only after some very unnecessary overthinking of an unorthodox notation; 2. "I do understand that you are just trying to transcribe somebody else's notation": that's a fundamental problem of transcription and for copyists in general. That notation is invalid: not only it exceeds the bar duration (a dotted bar line would at least made it more acceptable), but the repeat dots within the second ending are completely illogical, as there's no repeat after that. Considering (2) above: why should we reproduce that nonsense? It's just plain wrong. Jan 24 at 2:23
  • 2
    I started learning music with the piano, but most of my life I've preferred bagpipes. Bagpipe music notation is full of idiosyncrasies. Ending notation is one of them and this one is a doozy - one that I found in a tune by a famous piper held in very high regard. Documenting some of this weirdness is why I'm trying to replicate it in Lilypond.
    – Frotz
    Jan 24 at 21:05
  • @Frotz documenting odd/wrong cases is a quite specific requirement, and you should've probably highlighted that aspect in your post: we cannot know the real purpose of a question unless specified, and therefore we can (and should) only make assumptions based on educated guesses, especially considering the general purpose of a Q&A site such as SE ones. In your case, while those assumptions were "wrong", not only we couldn't know that until now, but, most importantly, anybody else's wouldn't, including inexperienced people that may find your post and believe that such a notation may be valid. Jan 25 at 6:08
  • @musicamante I see. I'll add something to the beginning to make this clear to others.
    – Frotz
    Jan 25 at 20:05

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.