Next: , Previous: Editorial and educational use, Up: Top


Text

adjusting-lyrics-vertical-spacing.ly

This snippets shows you how to bring the lyrics line closer to the Staff.

% Default layout:
\score{
  <<
    \new Staff \new Voice = m \relative c'{ c4 d e f g f e d c1}
    \new Lyrics \lyricsto m {aa aa aa aa aa aa aa aa aa }
  >>
}

% Reducing the minimum space below the Staff and above the Lyrics:

\score {
  <<
    \new Staff \with {
      \override VerticalAxisGroup #'minimum-Y-extent = #'(-1. 4)}
    \new Voice = m \relative c'{ c4 d e f g f e d c1 }
    \new Lyrics \with {
      \override VerticalAxisGroup #'minimum-Y-extent = #'(-1.2 . 1)}
    \lyricsto m {aa aa aa aa aa aa aa aa aa }
  >>

  \header {
    tagline = ""
  }
}

[image of music]

aligning-and-centering-instrument-names.ly

Instrument names are generally printed at the left side of the staves. To align the names of several different intruments, you can put them in a \markup block and use one of the following possibilites:

* Right-aligned instrument names: this is LilyPond's default behavior

* Center-aligned instrument names: with the \hcenter-in #n syntax, you can place the instrument names inside a padded box (n being the width of the box)

* Left-aligned instrument names: you have to print the names on top of an empty box, using the \combine command with a \hspace #n object.

\paper{ 
  indent = #0 
  left-margin = #30
  line-width = #160
}

\new StaffGroup \relative
<<
  \new Staff {
    \set Staff.instrumentName = "blabla"
    c1^"default" c1 \break 
    \set Staff.instrumentName = \markup { \hcenter-in #10 "blabla" }
    c1^"centered" c1 \break 
    \set Staff.instrumentName = \markup {\combine \hspace #8 "blabla" }
    c1^"left-aligned" c1 
    
  } 
  \new Staff {
    \set Staff.instrumentName = "blo"
    c1 c1 \break 
    \set Staff.instrumentName = \markup { \hcenter-in #10 "blo" }
    c1 c1 \break 
    \set Staff.instrumentName = \markup {\combine \hspace #8 "blo" }
    c1 c1 
  } 
  
>>

[image of music]

aligning-lyrics.ly

You can specify different horizontal alignment for your lyrics, by overriding the #'self-alignment-X property of the LyricText object. #-1 is left, #0 is center and #1 is right; however, you can use #LEFT, #CENTER and #RIGHT as well.

\relative c'' {
  c1 c c
}
\addlyrics {
  \once \override LyricText #'self-alignment-X = #LEFT "This is left-aligned" 
  \once \override LyricText #'self-alignment-X = #CENTER "This is centered" 
  \once \override LyricText #'self-alignment-X = #1 "this is right-aligned"  
}

[image of music]

blanking-staff-lines-using-the--whiteout-command.ly

The \whiteout command underlays a white box under a markup. Since staff lines are in a lower layer than most other grobs, this white box will not overlap any other grob.

\paper
{
  ragged-right = ##t
}
{
  \override TextScript #'extra-offset = #'(2 . 4)
  c'4-\markup  { \whiteout \pad-markup #0.5 foo } c
} 

[image of music]

center-text-below-hairpin-dynamics.ly

This example provides a function to typeset hairpin (de)crescendo with some additional text below it, such as "molto" or "poco".

The example also illustrates how to use modify the way an object normally is printed, using some Scheme code.

hairpinWithCenteredText = #(define-music-function
                          (parser location text) (markup?)
#{
\override Voice.Hairpin #'stencil = #(lambda (grob)
 (ly:stencil-aligned-to
  (ly:stencil-combine-at-edge
   (ly:stencil-aligned-to (ly:hairpin::print grob) X CENTER)
   Y
   DOWN
   (ly:stencil-aligned-to (ly:text-interface::print grob) X CENTER))
  X LEFT))
\override Voice.Hairpin #'text = $text
#})


hairpinMolto = \hairpinWithCenteredText \markup {\italic "molto"}
hairpinMore  = \hairpinWithCenteredText \markup {\bigger "moltissimo"}

\new Staff {
   \hairpinMolto c'2\< c'2\f
   \hairpinMore  c'2\< c'2\f
}

[image of music]

changing-the-default-text-font-family.ly

The default font families for text can be overridden with make-pango-font-tree.

\paper {
  % change for other default global staff size. 
  myStaffSize = #20
  %{
     run
         lilypond -dshow-available-fonts blabla
     to show all fonts available in the process log.  
  %}

  #(define fonts
    (make-pango-font-tree "Times New Roman"
                          "Nimbus Sans"
                          "Luxi Mono"
;;                        "Helvetica"
;;                        "Courier"
     (/ myStaffSize 20)))
}

\relative {
  c'^\markup {
    roman: foo \bold bla \italic bar \italic \bold baz 
  }
  c'_\markup {
    \override #'(font-family . sans)
    {
      sans: foo \bold bla \italic bar \italic \bold baz
    }
  }
  c'^\markup {
    \override #'(font-family . typewriter)
    {
      mono: foo \bold bla \italic bar \italic \bold baz
    }
  }
}  

[image of music]

combining-dynamics-with-markup-texts.ly

Some dynamics may involve text indications (such as "più forte", "piano subito", etc.). They can be produced using a \markup bloc.

\layout{ragged-right = ##t}

piuf =	\markup {  \italic "molto" \dynamic "f" }

\relative c''{
  c-\piuf
  c
  c2\< c2\!
  
  c2\< c2\!
}

[image of music]

combining-two-parts-on-the-same-staff.ly

The part combiner tool ( \partcombine command ) allows you to combine different parts on a same Staff. You can choose whether you want or don't want to add texts such as "solo" or "a2", by defining the printPartCombineTexts property.

For vocal scores (hymns), there is no need to add "solo"/"a2" texts, so they should be switched off. However, you'd better not use it if there are any solos, as they won't be indicated. In such cases, you may simply want to use standard LilyPond polyphony.

This snippet presents the three ways two parts can be printed on a same staff : standard polyphony, \partcombine whitout texts, and \partcombine with texts.

musicUp = {
  \time 4/4
  \relative c'' {
    a4 c4.(g8) a4 |
    g4 e' g,( a8 b) | 
    c b a2.
  }
}

musicDown = {
  \relative c'' {
    g4 e4.(d8) c4 |
    r2 g'4( f8 e) |
    d2 a
  }
}

\score{
  \new Staff {
    \set Staff.instrumentName = "Standard polyphony  "
    << \musicUp  \\ \musicDown >>
}

  \layout{ 
    indent = 6.0\cm 
  }
}

\score{
	\context Staff {
			\set Staff.instrumentName = "PartCombine without texts  "
			\partcombine \musicUp \musicDown
	}
	\layout{
		indent = 6.0\cm
		\context {
			\Voice
			printPartCombineTexts = ##f
		}
	}
}

\score{
	\context Staff {
			\set Staff.instrumentName = "PartCombine with texts  "
			\partcombine \musicUp \musicDown
	}
	\layout{
		indent = 6.0\cm
		\context {
			\Voice
			printPartCombineTexts = ##t
		}
	}
}

[image of music]

creating-real-parenthesized-dynamics.ly

Although the easiest way to add parenthesis to a dynamic mark is to use a \markup block, this method has a downside: the created objects will behave like text markups, and not like dynamics.

However, it is possible to create a similar object using the equivalent Scheme code (as described in "Markup programmer interface"), combined with the make-dynamic-script function. This way, the markup will be regarded as a dynamic, and therefore will remain compatible with commands such as \dynamicUp or \dynamicDown.

\paper { ragged-right = ##t }

parenF = #(make-dynamic-script (markup #:line(#:normal-text #:italic
#:fontsize 2 "(" #:hspace -0.8 #:dynamic "f" #:normal-text #:italic
#:fontsize 2 ")" )))

\score
{
       { c''\parenF c'' c'' \dynamicUp c''\parenF }
}

[image of music]

creating-text-spanners.ly

The <code>\startTextSpan</code> and <code>\stopTextSpan</code> commands give you the ability to create text spanners as easily as pedals indications or octavations. Override some properties of the <code>TextSpanner</code> object to modify its output.

\relative c''{
    \override TextSpanner  #'edge-text = #'("bla" . "blu")
    a \startTextSpan
    b c 
    a \stopTextSpan

    \override TextSpanner  #'dash-period = #2
    \override TextSpanner  #'dash-fraction = #0.0
    a \startTextSpan
    b c 
    a \stopTextSpan

    \revert TextSpanner #'style
    \override TextSpanner  #'style = #'dashed-line \override TextSpanner #'bound-details #'left #'text = \markup { \draw-line #'(0 . 1) }
 \override TextSpanner #'bound-details #'right #'text = \markup { \draw-line #'(0 . -2) }

    a \startTextSpan
    b c 
    a \stopTextSpan


    \set Staff.middleCPosition = #-13

    \override TextSpanner  #'dash-period = #10
    \override TextSpanner  #'dash-fraction = #.5
    \override TextSpanner  #'thickness = #10
    a \startTextSpan
    b c 
    a \stopTextSpan
    \set Staff.middleCPosition = #-6	
}

[image of music]

demonstrating-all-headers.ly

All header fields with special meanings.


[image of music]

formatting-lyrics-syllables.ly

To format single lyrics syllables, you can simply use \markup { .... } on these lyrics!

melody = \relative c'' { c4 c c c  }
lyr = \lyricmode { 
  Lyrics \markup { \italic can } \markup {\with-color #red contain } 
  \markup {\fontsize #8 \bold "Markup!" } 
}

\context Staff << 
  \context Voice = "mel" << \melody >>
  \context Lyrics \lyricsto "mel" \lyr
>>

[image of music]

how-to-put-ties-between-syllables-in-lyrics.ly

This can be achieved by separating those syllables by tildes.

\lyrics {
  wa~o~a 
}

[image of music]

markup-lines.ly

Text that can spread over pages is entered with the \markuplines command.

#(set-default-paper-size "a6")

#(define-markup-list-command (paragraph layout props args) (markup-list?)
  (interpret-markup-list layout props 
   (make-justified-lines-markup-list (cons (make-hspace-markup 2) args))))

%% Candide, Voltaire
\markuplines \override-lines #'(baseline-skip . 2.5) {
  \paragraph {
    Il y avait en Westphalie, dans le château de M. le baron de
    Thunder-ten-tronckh, un jeune garçon à qui la nature avait donné
    les mœurs les plus douces.  Sa physionomie annonçait son âme.
    Il avait le jugement assez droit, avec l'esprit le plus simple ;
    c'est, je crois, pour cette raison qu'on le nommait Candide.  Les
    anciens domestiques de la maison soupçonnaient qu'il était fils
    de la sœur de monsieur le baron et d'un bon et honnête
    gentilhomme du voisinage, que cette demoiselle ne voulut jamais
    épouser parce qu'il n'avait pu prouver que soixante et onze
    quartiers, et que le reste de son arbre généalogique avait été
    perdu par l'injure du temps.
  }
  \paragraph {
    Monsieur le baron était un des plus puissants seigneurs de la
    Westphalie, car son château avait une porte et des fenêtres.  Sa
    grande salle même était ornée d'une tapisserie.  Tous les chiens
    de ses basses-cours composaient une meute dans le besoin ; ses
    palefreniers étaient ses piqueurs; le vicaire du village était
    son grand-aumônier.  Ils l'appelaient tous monseigneur, et ils
    riaient quand il faisait des contes.
  }
}

[image of music]

ottava-text.ly

Internally, the set-octavation function sets the properties ottavation (e.g., to "8va" or "8vb") and middleCPosition. To override the text of the bracket, set ottavation after invoking set-octavation, like in the following example.

{
  #(set-octavation 1)
  \set Staff.ottavation = #"8"
  c''1
  #(set-octavation 0)
  c'1
  #(set-octavation 1)
  \set Staff.ottavation = #"Text"
  c''1
}

[image of music]

outputting-the-version-number.ly

By putting the output of lilypond-version into a lyric or a text markup, it is possible to print the version number of LilyPond in a score, or in a document generated with lilypond-book.

\score { \context Lyrics  {
    \override Score.RehearsalMark  #'self-alignment-X = #LEFT
    \mark #(ly:export (string-append "Processed with LilyPond version " (lilypond-version)))
    s2
  }
}

[image of music]

piano-template-with-centered-lyrics.ly

Instead of having a full staff for the melody and lyrics, you can place the lyrics between the piano staff (and omit the separate melody staff).

upper = \relative c'' {
            \clef treble
            \key c \major
            \time 4/4
         
            a b c d
         }
         
         lower = \relative c {
            \clef bass
            \key c \major
            \time 4/4
         
            a2 c
         }
         
         text = \lyricmode {
            Aaa Bee Cee Dee
         }
         
         \score {
           \new GrandStaff <<
             \new Staff = upper { \new Voice = "singer" \upper }
             \new Lyrics \lyricsto "singer" \text
             \new Staff = lower {
               \clef bass
               \lower
             }
           >>
           \layout {
             \context { \GrandStaff \accepts "Lyrics" }
             \context { \Lyrics \consists "Bar_engraver" }
           }
           \midi { }
         }

[image of music]

utf-8.ly

Various scripts may be used for texts (like titles and lyrics) introduced by entering them in UTF-8 encoding, and using a Pango based backend. Depending on the fonts installed, this fragment will render Bulgarian (Cyrillic), Hebrew, Japanese and Portuguese.

% end verbatim - this comment is a hack to prevent texinfo.tex
% from choking on non-European UTF-8 subsets
% Cyrillic font
bulgarian = \lyricmode {
  Жълтата дюля беше щастлива, че пухът, който цъфна, замръзна като гьон.
}

hebrew = \lyricmode { 
  זה כיף סתם לשמוע איך תנצח קרפד עץ טוב בגן.
}

japanese = \lyricmode {  
  いろはにほへど ちりぬるを
  わがよたれぞ  つねならむ
  うゐのおくや  まけふこえて
  あさきゆめみじ ゑひもせず 
}

% "a legal song to you"
portuguese = \lyricmode { 
  à vo -- cê uma can -- ção legal
}

\paper {
  ragged-right = ##t
}

\relative  { 
  c2 d e f g f e
}
\addlyrics { \bulgarian }
\addlyrics { \hebrew }
\addlyrics { \japanese }
\addlyrics { \portuguese }

[image of music]

vocal-ensemble-template-with-lyrics-aligned-below-and-above-the-staves.ly

This template is basically the same as the simple "Vocal ensemble" template, with the exception that here all the lyrics lines are placed using alignAboveContext and alignBelowContext.

global = {
           \key c \major
           \time 4/4
         }
         
         sopMusic = \relative c'' {
           c4 c c8[( b)] c4
         }
         sopWords = \lyricmode {
           hi hi hi hi
         }
         
         altoMusic = \relative c' {
           e4 f d e
         }
         altoWords =\lyricmode {
           ha ha ha ha
         }
         
         tenorMusic = \relative c' {
           g4 a f g
         }
         tenorWords = \lyricmode {
           hu hu hu hu
         }
         
         bassMusic = \relative c {
           c4 c g c
         }
         bassWords = \lyricmode {
           ho ho ho ho
         }
         
         \score {
           \new ChoirStaff <<
              \new Staff = women <<
                 \new Voice =
                   "sopranos" { \voiceOne << \global \sopMusic >> }
                 \new Voice =
                   "altos" { \voiceTwo << \global \altoMusic >> }
              >>
              \new Lyrics \with {alignAboveContext=women} \lyricsto sopranos \sopWords
              \new Lyrics \with {alignBelowContext=women} \lyricsto altos \altoWords
         % we could remove the line about this with the line below, since we want
         % the alto lyrics to be below the alto Voice anyway.
         %    \new Lyrics \lyricsto altos \altoWords
         
              \new Staff = men <<
                 \clef bass
                 \new Voice =
                   "tenors" { \voiceOne <<\global \tenorMusic >> }
                 \new Voice =
                   "basses" { \voiceTwo <<\global \bassMusic >> }
              >>
         
              \new Lyrics \with {alignAboveContext=men} \lyricsto tenors \tenorWords
              \new Lyrics \with {alignBelowContext=men} \lyricsto basses \bassWords
         % again, we could replace the line above this with the line below.
         %    \new Lyrics \lyricsto basses \bassWords
           >>
         
           \layout {
              \context {
                 % a little smaller so lyrics
                 % can be closer to the staff
                 \Staff
                 \override VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3)
              }
           }
         }
         
         
         \score {
           \new ChoirStaff <<
              \new Staff = women <<
                 \new Voice =
                   "sopranos" { \voiceOne << \global \sopMusic >> }
                 \new Voice =
                   "altos" { \voiceTwo << \global \altoMusic >> }
              >>
         
              \new Lyrics \with {alignAboveContext=women} \lyricsto sopranos \sopWords
              \new Lyrics \lyricsto altos \altoWords
         
              \new Staff = men <<
                 \clef bass
                 \new Voice =
                   "tenors" { \voiceOne <<\global \tenorMusic >> }
                 \new Voice =
                   "basses" { \voiceTwo <<\global \bassMusic >> }
              >>
         
              \new Lyrics \with {alignAboveContext=men} \lyricsto tenors \tenorWords
              \new Lyrics \lyricsto basses \bassWords
           >>
         
           \layout {
              \context {
                 % a little smaller so lyrics
                 % can be closer to the staff
                 \Staff
                 \override VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3)
              }
           }
         } 

[image of music]



Next: , Previous: Editorial and educational use, Up: Top

This page is for LilyPond-2.11.40 (development-branch).

Report errors to http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs.

Your suggestions for the documentation are welcome.