4

I am working on a purely personal project. Unfortunately technology is getting in my way. Included at imgur are two images, one is correct the other has the bottom cut off. Is there anyway of overcoming this? If you set the bottom staff to tenor it cuts off the bottom of the render but if it is set to treble it renders properly.

The fragment in question is:

<lilypond>
\layout {
#(layout-set-staff-size 25)
}
\new StaffGroup <<
\new Staff = "up" {
    \voiceOne
    c'1 d' e' f' g' a' b' c''
}
\new Staff = "down" {
    \clef treble
    \voiceTwo
    c'1 c' c' c' c' c' c' c'
}
>>
</lilypond>

https://imgur.com/a/RFyeHJB

  • I suspect, this is related to how you produce the png files, which can't be seen from the code above. – guidot Dec 4 '19 at 16:17
  • Put that code in a files called book.lytex and create a directory out and run the following command. lilypond-book --output=out -f html book.lytex The down side is; looking at the lilypond docs, they have the same issue all over their examples. I may not be able to use lilypond.... – Bill Jones Dec 4 '19 at 16:37
4

This seems to be a problem with the way LilyPond handles the so-called grobs. The system bracket obviously has a height of zero, so that it does not affect the clipped area, but instead gets clipped itself.

Anyways, as soon as you type notes into the lower staff that reach below the lowest staff line or if you append things below staff (such as dynamics or lyrics), the problem will disappear, because then, there is something below the lowest staff line that LilyPond has to render and the clipping is correct.

So, the one way to solve this is to tell LilyPond that there is something it has to render below the lowest staff line. This can be done for example by telling LilyPond to print transparent bar numbers below the staff groups like this:

<lilypond>
\layout {
  #(layout-set-staff-size 25)
  \context {
    \Score
    barNumberVisibility = #all-bar-numbers-visible % print bar numbers in every line
    \override BarNumber.direction = #DOWN          % print bar numbers below staff
    \override BarNumber.transparent = ##t          % make bar numbers transparent
  }
}
\new StaffGroup << 
\bar ""                                            % force printing of first bar number
\new Staff = "up" {
  \voiceOne 
  c'1 d' e' f' g' a' b' c'' 
}
\new Staff = "down" {
  \clef tenor 
  \voiceTwo
  c'1 c' c' c' c' c' c' c'
}
>>
</lilypond>

If you render this with the same command you used, namely lilypond-book --output=out -f html book.lytex (assumed your original file is called “book.lytex”), you will get the following result:

enter image description here


Edit

After another round of googling, I found a better (i.e. cleaner) solution that re-calculates the height of the system bracket. It seems that this solution also works in your set up. Placing the original code into your snippet would look like this:

<lilypond>
\layout {
  #(layout-set-staff-size 25)
  \context {
    \Score
    \override SystemStartBracket.after-line-breaking =
    #(lambda (grob)
     (if (defined? 'default-toplevel-book-handler)
       (let ((Y-off (ly:grob-property grob 'Y-extent)))
         (ly:grob-set-property! grob 'Y-extent
           (cons (- (car Y-off) 1.7) (+ (cdr Y-off) 1.7))))))
  }
}
\new StaffGroup << 
\new Staff = "up" {
  \voiceOne 
  c'1 d' e' f' g' a' b' c'' 
}
\new Staff = "down" {
  \clef tenor 
  \voiceTwo
  c'1 c' c' c' c' c' c' c'
}
>>
</lilypond>
  • 1
    Thanks for running the example as I cant get to my server at home; but from your run that fixed it. I really appreciate the effort you put in to solving it. – Bill Jones Dec 4 '19 at 20:25
  • 2
    The second solution is not really my invention, but because I really like the approach, I just copied the code from the linked reference and placed it into your code. So, if you want to thank someone, also consider the guy who came up with this idea in the first place =) – Jasper Habicht Dec 4 '19 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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