3

How do I tell Lilypond which side of a stem I want individual chord tones on?

With a simple chord in single angle brackets, like <e g b> <e a c>, the note heads all go to the left (default) side of the upwards-extending (default) stem.

With the chord <f g b>, Lilypond puts the F and B on the left, and the G on the right. I'd like the F on the left, and the G and B on the right. But I can't find any reference to any way to control which side they are placed on. I haven't even found a clear reference to which object makes the decision.

2
  • 3
    I don't think it can be set in any (easy) way, because there are "stylistic" rules for these situations and Lilypond adheres to these. As far as I know, a note head can appear on the "wrong" side of a stem only if there is another head on the adjacent line/space, and in that case the lower note is on the left. So with stem up, left is the right place to put them, and so the B is put on the left (then F on the left because it is the lower one, and G on the right).
    – Ramillies
    Oct 20, 2021 at 8:58
  • Easy would be nice, but is beside the point. My understanding is that those rules are implemented SOMEWHERE in Lilypond's internals, and can in almost every case be modified and overridden. i can move the note heads by brute force, but that's not the correct way, and Lilypond's documents explain why. It's just that there are many levels to this, and I'm not confident that "it can't be done" rather than "I didn't find the answer" is correct.
    – KFW
    Oct 20, 2021 at 10:20

1 Answer 1

1

This solution may be a start. It's a function to offset a note individually. The value 1.2 is the amount needed to shift the note to the other side of the stem.

horOff =
#(define-music-function (parser location x-off music) (number? ly:music?)
         (set! (ly:music-property music 'tweaks)
        (acons 'extra-offset (cons x-off 0)
         (ly:music-property music 'tweaks)))
   music)

\relative c' {
  <f g b>
  <f g \horOff #1.2 b>
}

I found it here: https://lists.gnu.org/archive/html/lilypond-user/2012-04/msg00134.html

Try other solutions presented in this thread if the one above does not work for you.

1
  • It works as the last thing I do before printing. It is exactly what Lilypond docs tell me not to do - forcibly move graphic objects by fixed measurements. The rest of Lilypond doesn't recognize those tweaks, or rescale them, or accomodate other objects to them. They kind of sort of attempt to address that. There is a place, somewhere in Lilypond's code, where the note heads are assigned to the right or left of the stem, rather than a pixel location. That is the part of the code I'm seeking access to.
    – KFW
    Nov 14, 2021 at 23:51

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.