1

I'm using the following bit of code to add lyrics to only the last 2 notes of a song. This section of code is used for all of the instruments in my score.

d4-> 4-> 4-> r4
<<
  {\override NoteHead.style = #'cross
    ees\accent 4\accent 4\accent r4 \fine
  }\addlyrics{Go Big}
>>

However, when I just this in the score, all of the lyrics text becomes clumped up at the bottom of the score. What can I do to fix this?

enter image description here

2
  • 1
    Can you edit your post so that it has an example of the code not working with just two staves? Note that the code should compile even if it does do what you want it to.
    – ksnortum
    Commented May 24 at 21:58
  • As is, your code fragment doesn’t compile. Simply wrapping it braces ({ & }) works, but it still doesn’t match with your image. Please edit your question so that it contains an MWE (Minimal Working Example) such as the first codeblock in Lazy’s answer, and so that the image matches the code. (This makes it much easier for those trying to help.) Commented May 25 at 4:56

1 Answer 1

2

A reduced example of you problem:

<<
  \new Staff { c' { c' } \addlyrics { Cee } }
  \new Staff { c' { c' } \addlyrics { Cee } }
>>

Two staffs with lyrics appearing below both.

The problem here is the order in which the contexts are created. As the \addlyrics only happen in a later place the Lyrics contexts are created after the Staves, thus placing them beyond them. While you could of course create these Lyrics contexts manually and tell LilyPond to put them under the respective staff contexts, I’d rather suggest putting the special-case notes in named voices and then aligning the Lyrics to these voices:

<<
  \new Staff { c' \new Voice = "final1" { c' } }
  \new Lyrics \lyricsto "final1" { Cee }
  \new Staff { c' \new Voice = "final2" { c' } }
  \new Lyrics \lyricsto "final2" { Cee }
>>

Two staffs with lyrics appearing below each.

If you need lyrics in different places you can even do something like this:

withVoice =
#(define-music-function (name mus) (string? ly:music?)
   #{
     <<
       \new Voice = #name \skip $mus
       $mus
     >>
   #})

<<
  \new Staff \withVoice "final1" {
    c' \context Voice = "final1"
    c' d' \context Voice = "final1" d'
  }
  \new Lyrics \lyricsto "final1" { Cee Dee }
  \new Staff \withVoice "final2" {
    c' \context Voice = "final2"
    c' d' \context Voice = "final2" d'
  }
  \new Lyrics \lyricsto "final2" { Cee Dee }
>>

Two staffs with lyrics appearing below each.

(although keep in mind that notes with lyrics are in a different voice, which might cause issues with beams, slurs and stuff).

Of course one could also try something like this:

withVoice =
#(define-music-function (name mus) (string? ly:music?)
   #{
     <<
       \new NullVoice = #name \skip $mus
       $mus
     >>
   #})

allowLyrics =
#(define-music-function (name mus) (string? ly:music?)
   #{
     <<
       $mus
       \context Voice = #name $mus
     >>
   #})

<<
  \new Staff \withVoice "final1" {
    c' \allowLyrics "final1"
    c' d' \allowLyrics "final1" d'
  }
  \new Lyrics \lyricsto "final1" { Cee Dee }
  \new Staff \withVoice "final2" {
    c' \allowLyrics "final2"
    c' d' \allowLyrics "final2" d'
  }
  \new Lyrics \lyricsto "final2" { Cee Dee }
>>

Two staffs with lyrics appearing below each.

5
  • 1
    I'd like this answer even more if you added at least one example of rendered output that looks correct. Commented May 24 at 23:45
  • @ToddWilcox I’m not exactly sure why? Looking at the OP’s problem I think it is clear what he wants, and it is quite clear how this is supposed to look. What is the advantage of showcasing something that is clear in the first place?
    – Lazy
    Commented May 25 at 19:23
  • Everything you say is “clear” might be clearer to you than it is to others. Commented May 25 at 21:07
  • @ToddWilcox If anything were unclear it should be clarified in the question, not in the answer. But I think here it is quite obvious that the OP expects to see the lyrics between the staves rather than under the staff. My answer does not add anything else, so I see no benefit of explaining the intent of the question. In other cases I’d be with you, where maybe you custom draw some stuff or whatever. But here what would this do apart from maybe proving that my code works as intended?
    – Lazy
    Commented May 25 at 21:57
  • There’s no point in continuing this discussion. I gave you my opinion and you don’t agree. You’re not going to talk me out of my opinion and I’m not going to talk you out of yours. Commented May 25 at 23:09

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.