Next: , Previous: Other uses for tweaks, Up: Further tweaking


4.6.2 Using variables for tweaks

Override commands are often long and tedious to type, and they have to be absolutely correct. If the same overrides are to be used many times it may be worth defining variables to hold them. Suppose we wish to emphasize certain words in lyrics by printing them in bold italics. The \italic and \bold commands do not work within lyrics so we must instead use the following \override and \revert commands:

\override Lyrics . LyricText #'font-shape = #'italic
\override Lyrics . LyricText #'font-series = #'bold

\revert Lyrics . LyricText #'font-shape
\revert Lyrics . LyricText #'font-series

These would be extremely tedious to enter if there were many words requiring emphasis. So instead we define these as two variables, and use them as follows:

     
     emph = {
       \override Lyrics . LyricText #'font-shape = #'italic
       \override Lyrics . LyricText #'font-series = #'bold
     }
     norm = {
       \revert Lyrics . LyricText #'font-shape
       \revert Lyrics . LyricText #'font-series
     }
     
     global = { \time 4/4 \partial 4 \key c \major}
     SopMusic   = \relative c' { c4 | e4. e8 g4  g  | a a g }
     AltoMusic  = \relative c' { c4 | c4. c8 e4  e  | f f e }
     TenorMusic = \relative c  { e4 | g4. g8 c4. b8 | a8 b c d e4 }
     BassMusic  = \relative c  { c4 | c4. c8 c4  c  | f8 g a b c4 }
     VerseOne   = \lyrics { E -- | ter -- nal \emph Fa -- ther, \norm | strong to save, }
     VerseTwo   = \lyricmode { O | \emph Christ, \norm whose voice the | wa -- ters heard, }
     VerseThree = \lyricmode { O | \emph Ho -- ly Spi -- rit, \norm | who didst brood }
     VerseFour  = \lyricmode { O | \emph Tri -- ni -- ty \norm of | love and pow'r }
     
     \score {
       \new ChoirStaff <<
         \new Staff <<
           \clef "treble"
           \new Voice = "Sop"  { \voiceOne \global \SopMusic }
           \new Voice = "Alto" { \voiceTwo \AltoMusic }
           \new Lyrics \lyricsto "Sop" { \VerseOne   }
           \new Lyrics \lyricsto "Sop" { \VerseTwo   }
           \new Lyrics \lyricsto "Sop" { \VerseThree }
           \new Lyrics \lyricsto "Sop" { \VerseFour  }
         >>
         \new Staff <<
           \clef "bass"
           \new Voice = "Tenor" { \voiceOne \TenorMusic }
           \new Voice = "Bass"  { \voiceTwo \BassMusic  }
         >>
       >>
     }

[image of music]



Next: , Previous: Other uses for tweaks, Up: Further tweaking

Esta pƔgina corresponde a LilyPond-2.11.40 (rama de desarrollo).

Informe de los fallos a http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs.

Se agradecen las sugerencias para la documentación.