Lilypond技术问题:如何为反斜杠创建的临时声部添加歌词
Hey there! Let's sort out this lyric alignment issue with temporary voices in LilyPond that you're stuck on.
First, let's break down why your initial attempts weren't working: when you use <<{ }\\{ }>> to create those quick temporary voices, they're nested as sub-voices under your main "soprano" voice. If you only bind lyrics to the main voice, LilyPond ignores the nested sub-voices for lyric placement. And when you tried inserting a \new Lyrics inside the temporary voice block, that created a standalone Lyrics context that didn't properly attach to the sub-voice—hence why it ended up at the bottom of the score.
Luckily, there are two solid ways to fix this, both centered on properly binding lyrics to those temporary sub-voices:
Method 1: Explicitly Name Your Temporary Voices
This is the most straightforward and readable approach, especially if you work with temporary voices often. Just give each sub-voice a clear name, then create separate Lyrics contexts bound to each one:
LyricsMain = \lyricmode {Et lux per } LyricsUpperTemp = \lyricmode {pe -- tu --} LyricsLowerTemp = \lyricmode {a } \score { \new ChoirStaff << \new Voice = "soprano" \relative c' { \clef treble c4 f8 f << \new Voice = "temp-upper" {a a} \\ \new Voice = "temp-lower" {f f} >> c'4 } \new Lyrics \lyricsto "soprano" { \LyricsMain } \new Lyrics \lyricsto "temp-upper" \alignBelow { \LyricsUpperTemp } \new Lyrics \lyricsto "temp-lower" \alignAbove { \LyricsLowerTemp } >> }
- By naming the sub-voices (
temp-upperandtemp-lower), you can directly reference them in\lyricsto. - Use
\alignBelowand\alignAboveto position the lyrics so they don't overlap with each other or the main voice's lyrics.
Method 2: Use LilyPond's Default Temporary Voice Names
LilyPond automatically names the first sub-voice in <<{ }\\{ }>> as "1" and the second as "2". You can bind lyrics directly to these default names if you prefer not to add custom names:
LyricsMain = \lyricmode {Et lux per } LyricsSub1 = \lyricmode {pe -- tu --} LyricsSub2 = \lyricmode {a } \score { \new ChoirStaff << \new Voice = "soprano" \relative c' { \clef treble c4 f8 f <<{a a}\\{f f}>> c'4 } \new Lyrics \lyricsto "soprano" { \LyricsMain } \new Lyrics \lyricsto "1" \alignBelow { \LyricsSub1 } \new Lyrics \lyricsto "2" \alignAbove { \LyricsSub2 } >> }
This works just as well, though custom names make your code easier to follow if you have multiple temporary voice blocks in the same score.
The key takeaway is that you need to create separate Lyrics contexts at the ChoirStaff level (not inside the voice block) and bind each to the specific sub-voice you want the lyrics to follow. That way, LilyPond knows exactly which notes to align the lyrics with, no more skipping or misplaced text!
内容的提问来源于stack exchange,提问作者Pgking

