Lyrics above the staff they are assigned to: Difference between revisions
Appearance
m New category Tags: Mobile edit Mobile web edit |
I updated the code for version 2.26 and made some improvements. |
||
| Line 1: | Line 1: | ||
Lyrics can also be placed above the staff to which they are assigned | Lyrics can also be placed above the staff to which they are assigned. However, in this case you cannot simply place the line with <code>\lyricsto</code> above the staff definition, because at that point the voice to which the lyrics are assigned has not been created. Thus, you have to insert an empty dummy definition | ||
<pre> \new Lyrics = "lyricsname" { s4 } | <pre> \new Lyrics = "lyricsname" { s4 } | ||
| Line 6: | Line 6: | ||
<pre> \context Lyrics = "lyricsname" \lyricsto "voicename" \lyricsdefinition</pre> | <pre> \context Lyrics = "lyricsname" \lyricsto "voicename" \lyricsdefinition</pre> | ||
This snippet | This snippet shows a simple example of how to add lyrics above and/or below the staff. | ||
<lilypond version="2. | <lilypond version="2.26"> | ||
%% http://lsr.di.unimi.it/LSR/Item?id=391 | %% Place lyrics above the staff to which they are assigned | ||
%% https://wiki.lilypond.community/wiki/Lyrics_above_the_staff_they_are_assigned_to | |||
%% formerly http://lsr.di.unimi.it/LSR/Item?id=391 | |||
notes = \relative c' { c4 d e f | g a b c | } | |||
lyricsAbove = \lyricmode { These ly -- rics placed a -- bove the staff… } | |||
lyricsBelow = \lyricmode { These ly -- rics placed be -- low the staff… } | |||
notes = \relative c' { c4 d e f | g a b c |} | |||
lyricsAbove = \lyricmode { These ly -- rics placed a -- bove the | |||
lyricsBelow = \lyricmode { These ly -- rics placed be -- low the | |||
\score { | \score { | ||
% Wrap everything in a parallel music section (otherwise | % Wrap everything in a parallel music section (otherwise you’ll get errors!) | ||
<< | << | ||
% | % Create empty dummy lyrics contexts. We’ll do the actual assignment later. | ||
% Important: The names will later be used to assign the correct placement! | % Important: The names will later be used to assign the correct placement! | ||
% We | % We can’t do the assignment before the voice has been defined, so the | ||
% first Lyrics | % first Lyrics can’t be replaced by \lyricsto, because the voice to which | ||
% it is assigned is not yet created there!!! | % it is assigned is not yet created there!!! | ||
% Lyrics above (because created before the staff) | % Lyrics above (because created before the staff) | ||
\new Lyrics = "above" { s4 } | \new Lyrics = "above" { s4 } | ||
| Line 35: | Line 33: | ||
% Lyrics below (because created after the staff) | % Lyrics below (because created after the staff) | ||
\new Lyrics = "below" { s4 } | \new Lyrics = "below" { s4 } | ||
% Now that we have created the Lyrics objects in the correct order, assign the lyrics | % Now that we have created the Lyrics objects in the correct order, assign the lyrics. | ||
% Notice the Lyrics = "name", where name is the same as in the above definitions! | % Notice the Lyrics = "name", where name is the same as in the above definitions! | ||
\context Lyrics = "above" \lyricsto "mainvoice" \lyricsAbove | \context Lyrics = "above" \lyricsto "mainvoice" \lyricsAbove | ||
Latest revision as of 13:24, 26 June 2026
Lyrics can also be placed above the staff to which they are assigned. However, in this case you cannot simply place the line with \lyricsto above the staff definition, because at that point the voice to which the lyrics are assigned has not been created. Thus, you have to insert an empty dummy definition
\new Lyrics = "lyricsname" { s4 }
\new Staff = "staffname" << .... >>
and do the actual lyrics assignment later:
\context Lyrics = "lyricsname" \lyricsto "voicename" \lyricsdefinition
This snippet shows a simple example of how to add lyrics above and/or below the staff.
\version "2.26"
%% Place lyrics above the staff to which they are assigned
%% https://wiki.lilypond.community/wiki/Lyrics_above_the_staff_they_are_assigned_to
%% formerly http://lsr.di.unimi.it/LSR/Item?id=391
notes = \relative c' { c4 d e f | g a b c | }
lyricsAbove = \lyricmode { These ly -- rics placed a -- bove the staff… }
lyricsBelow = \lyricmode { These ly -- rics placed be -- low the staff… }
\score {
% Wrap everything in a parallel music section (otherwise you’ll get errors!)
<<
% Create empty dummy lyrics contexts. We’ll do the actual assignment later.
% Important: The names will later be used to assign the correct placement!
% We can’t do the assignment before the voice has been defined, so the
% first Lyrics can’t be replaced by \lyricsto, because the voice to which
% it is assigned is not yet created there!!!
% Lyrics above (because created before the staff)
\new Lyrics = "above" { s4 }
\new Staff <<
\new Voice = "mainvoice" << \notes >>
>>
% Lyrics below (because created after the staff)
\new Lyrics = "below" { s4 }
% Now that we have created the Lyrics objects in the correct order, assign the lyrics.
% Notice the Lyrics = "name", where name is the same as in the above definitions!
\context Lyrics = "above" \lyricsto "mainvoice" \lyricsAbove
\context Lyrics = "below" \lyricsto "mainvoice" \lyricsBelow
>>
}