I'm trying to make music-snippet images using lilypond, but I'd like each snippet to always have trailing "whitespace" so that each of these images is of the same width.

I'm following the suggestions from the documentation, so I have a .ly file something like:

    bookTitleMarkup = ##f
    scoreTitleMarkup = ##f
    \relative c' { c4 d e f | g a b c } %insert whitespace to fill line here

and compile it using

$>lilypond -dbackend=eps -dno-gs-load-fonts -dinclude-eps-fonts --png test.ly

and it produces a file that is 241 pixels wide.

If I make the snippet three bars, with c4 d e f | g a b c | c b a g, I get a file that is 335 pixels wide.

Ultimately, I'm going to insert these images into a document, and I'd like to be able to use the same width for all of the images, and have the staff/notes be the same size.

I don't want to key off of the height of the images (which is the same) in this case, because some of the snippets will span multiple lines.

  • 1
    May I refer you to the LilyPond Users mailing list!? See also my answer on this question: meta.stackexchange.com/questions/168297/…
    – PeterBjuhr
    Nov 5, 2013 at 19:44
  • I am a novice when it comes to Lilypond, but I'd try to achieve this by padding the shorter snippets with invisible dummy notes. Apr 25, 2014 at 18:44
  • I'm putting them into an org-mode document; I have found that in that context I always want to set the figure width; to keep myself sane, I want to be able to set the same width for all of the snippets -- thus I want Lilypond to do the padding for me.
    – Dave
    Apr 25, 2014 at 22:45

1 Answer 1


You can fix this by adding in the \paper section:

  ragged-last = ##f

This will ensure that if your score is only one line, it will use the full line width you've specified.

  • True but not the solution I'm looking for -- short snippets get stretched out to fill the line, resulting in unattractively large spaces between the notes.
    – Dave
    Apr 25, 2014 at 18:03
  • I see, so you really want completely white space to fill the right. I don't know what you're using to write the final document, but it seems like if you can left-justify your images to the desired margin, you should be all set with your original lilypond source. You'll end up with appropriate white space in the document itself rather than in the image you insert to the document, and you'll still have the peace of mind knowing that the line-width you set in lilypond will keep things from overflowing to the right. Apr 25, 2014 at 21:25

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.