Le dimanche 19 février 2023 à 08:57 +0800, Darren Ng a écrit :
> In the following sheet,  
> "Dave" and "Ed" are not on the same line.
> 
> How to properly group melodies and their matching lyrics into variables,  
> while keeping lyrics on the same line?
> 
>     \version "2.24.1"  
>     segmentA = {<<  
>       { c4 c4 c4 c8 r8 }  
>       \addlyrics { Alice Bob Cathy Dave }  
>     >>}  
>     segmantB = { <<  
>       { d4 d4 d4 d8 r8 }  
>       \addlyrics { Ed Fred Greg Howl }  
>     >>}  
>     \score {  
>       \relative c'' {  
>         \clef "treble" \numericTimeSignature \time 4/4  
>         \segmentA  
>         \segmantB  
>       }  
>       \layout { }  
>     }
> 


You need to name the contexts when you create them in order to continue them 
afterwards with `\context`.

```
\version "2.24.1"

segmentA = <<
  \new Voice = song { c4 c4 c4 c8 r8 }
  \new Lyrics = lyrics \lyricsto song { Alice Bob Cathy Dave }
>>

segmentB = <<
  \context Voice = song { d4 d4 d4 d8 r8 }
  \context Lyrics = lyrics \lyricsto song { Ed Fred Greg Howl }
>>

\score {
  \relative c'' {
    \clef "treble" \numericTimeSignature \time 4/4
    \segmentA
    \segmentB
  }
  \layout { }
}
```

Alternatively, just make more variables.

```
\version "2.24.1"

segmentA = { c4 c4 c4 c8 r8 }
segmentB = { d4 d4 d4 d8 r8 }

lyricsA = \lyricmode { Alice Bob Cathy Dave }
lyricsB = \lyricmode { Ed Fred Greg Howl }

\score {
  \relative c'' {
    \clef "treble" \numericTimeSignature \time 4/4
    { \segmentA \segmentB }
    \addlyrics { \lyricsA \lyricsB }
  }
  \layout { }
}
```


See 
[https://lilypond.org/doc/v2.24/Documentation/notation/common-notation-for-vocal-music#aligning-lyrics-to-a-melody](https://lilypond.org/doc/v2.24/Documentation/notation/common-notation-for-vocal-music#aligning-lyrics-to-a-melody)
 and 
[https://lilypond.org/doc/v2.24/Documentation/notation/creating-and-referencing-contexts](https://lilypond.org/doc/v2.24/Documentation/notation/creating-and-referencing-contexts).

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to