On 2019-02-28 8:53 pm, David F. wrote:
Given a line of lyrics with the stanza number in front, how can I move
the stanza number (“1.”) so that it is above the first syllable of the
lyrics instead of to the left of the lyrics?

\version "2.19"

\new Voice \relative {
    \time 3/4 g'2 e4 a2 f4 g2.
}
\addlyrics {
    \set stanza = #"1. "
    Hi, my name is Bert.
}

%%%%
\version "2.19.82"

\layout { \context { \Lyrics
  \override StanzaNumber.direction = #UP
  \override StanzaNumber.side-axis = #Y
  \override StanzaNumber.self-alignment-X = #CENTER
\override StanzaNumber.X-offset = #ly:self-alignment-interface::aligned-on-x-parent \override StanzaNumber.Y-offset = #ly:side-position-interface::y-aligned-side
} }

\new Voice \relative { \time 3/4 g'2 e4 a2 f4 g2. }
\addlyrics { \set stanza = #"1." Hi, my name is Bert. }
%%%%

The above snippet cheats a little because StanzaNumber does not actually support self-alignment-interface, but it is reusing some code to ensure the text is centered to the parent note.

It would be possible to support alignment to the LyricText with a little extra work. The following left-aligns the StanzaNumber to the supporting text:

%%%%
\version "2.19.82"

\layout { \context { \Lyrics
  \override StanzaNumber.direction = #UP
  \override StanzaNumber.side-axis = #Y
  \override StanzaNumber.X-offset = #(lambda (grob)
    (let* ((sse (ly:grob-object grob 'side-support-elements))
           (lyr (car (ly:grob-array->list sse)))
           (xoff (ly:grob-property lyr 'X-offset)))
      xoff))
\override StanzaNumber.Y-offset = #ly:side-position-interface::y-aligned-side
} }

\new Voice \relative { \time 3/4 g'2 e4 a2 f4 g2. }
\addlyrics { \set stanza = #"1." Hi, my name is Bert. }
%%%%

-- Aaron Hill

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to