Frammenti LilyPond: Text

# Text

Text

## Adding markups in a tablature

By default markups does not show in a tablature.

To make them appear, simply use the command `\revert TabStaff.TextScript.stencil`

    %% http://lsr.di.unimi.it/LSR/Item?id=919
    % by P.P.Schneider on June 2014

    high  = { r4 r8 <g c'> q r8 r4 }

    low = { c4 r4 c8 r8 g,8 b, }

    pulse = { s8^"1" s^"&" s^"2" s^"&" s^"3" s^"&" s^"4" s^"&" }

    \score {
     \new TabStaff {
       \repeat unfold 2 << \high \\ \low \\ \pulse >>
      }
      \layout {
        \context {
          \TabStaff
          \clef moderntab
          \revert TextScript.stencil
          \override TextScript.font-series = #'bold
          \override TextScript.font-size = #-2
          \override TextScript.color = #red

        }
        \context {
          \Score
          proportionalNotationDuration = #(ly:make-moment 1/8)
        }
      }
    }

## Adding the current date to a score

With a little Scheme code, the current date can easily be added to a score.

    % first, define a variable to hold the formatted date:
    date = #(strftime "%d-%m-%Y" (localtime (current-time)))

    % use it in the title block:
    \header {
      title = "Including the date!"
      subtitle = \date
    }

    \score {
      \relative c'' {
        c4 c c c
      }
    }
    % and use it in a \markup block:
    \markup {
      \date
    }

## Adjusting lyrics vertical spacing

This snippet shows how to bring the lyrics line closer to the staff.

    % Default layout:
    <<
      \new Staff \new Voice = melody \relative c' {
        c4 d e f
        g4 f e d
        c1
      }
      \new Lyrics \lyricsto melody { aa aa aa aa aa aa aa aa aa }

      \new Staff {
        \new Voice = melody \relative c' {
          c4 d e f
          g4 f e d
          c1
        }
      }
      % Reducing the minimum space below the staff and above the lyrics:
      \new Lyrics \with {
        \override VerticalAxisGroup.nonstaff-relatedstaff-spacing =
          #'((basic-distance . 1))
      }
      \lyricsto melody { aa aa aa aa aa aa aa aa aa }
    >>

## Aligning and centering instrument names

The horizontal alignment of instrument names is tweaked by changing the `Staff.InstrumentName #'self-alignment-X` property. The `\layout` variables `indent` and `short-indent` define the space in which the instrument names are aligned before the first and the following systems, respectively.

    \paper { left-margin = 3\cm }

    \score {
      \new StaffGroup <<

        \new Staff \with {
          \override InstrumentName.self-alignment-X = #LEFT
          instrumentName = \markup \left-column {
            "Left aligned"
            "instrument name"
            }
            shortInstrumentName = "Left"
          }

          {  c''1 \break c''1 }

        \new Staff \with {
          \override InstrumentName.self-alignment-X = #CENTER
          instrumentName = \markup \center-column {
            Centered
            "instrument name"
            }
          shortInstrumentName = "Centered"
        }

        { g'1 g'1}

        \new Staff \with {
          \override InstrumentName.self-alignment-X = #RIGHT
          instrumentName = \markup \right-column {
            "Right aligned"
            "instrument name"
          }
          shortInstrumentName = "Right"
        }

        { e'1 e'1 }

      >>

      \layout {
        ragged-right = ##t
        indent = 4\cm
        short-indent = 2\cm
      }
    }

## Aligning objects created with the `\mark` command

By default the `\mark` command centers objects over a bar line. This behavior can be modified to align at right or left.

    \relative c' {
      c1 \mark "(Center)"
      c1
      \once \override Score.RehearsalMark.self-alignment-X = #LEFT
      \mark "(Left)"
      c4 c c c
      c4 c c c
      \once \override Score.RehearsalMark.self-alignment-X = #RIGHT
      \mark "(Right)"
      c1
    }

## Aligning syllables with melisma

By default, lyrics syllables that start a melisma are left aligned on their note. The alignment can be altered using the `lyricMelismaAlignment` property.

    \score {
      <<
        \new Staff {
          \relative c''
          \new Voice = "vocal" {
            c d~^\markup default  d e
            c d~^\markup "right aligned" d e
            c d~^\markup "center aligned" d e
            c d~^\markup "reset to default" d e
          }
        }
        \new Lyrics \lyricsto "vocal" {
          word word word
          \set lyricMelismaAlignment = #RIGHT
          word word word
          \set lyricMelismaAlignment = #CENTER
          word word word
          \unset lyricMelismaAlignment
          word word word
        }
      >>
    }

## Blanking staff lines using the \whiteout command

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

    \layout {
      ragged-right = ##f
    }

    \relative c' {
      \override TextScript.extra-offset = #'(2 . 4)
      c2-\markup { \whiteout \pad-markup #0.5 "middle C" } c
    }

## Center text below hairpin dynamics

This example provides a function to typeset a hairpin (de)crescendo with some additional text below it, such as “molto” or “poco”. The added text will change the direction according to the direction of the hairpin. The Hairpin is aligned to DynamicText.

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

    hairpinWithCenteredText =
    #(define-music-function (text) (markup?)
      #{
        \once \override Voice.Hairpin.after-line-breaking =
          #(lambda (grob)
            (let* ((stencil (ly:hairpin::print grob))
                   (par-y (ly:grob-parent grob Y))
                   (dir (ly:grob-property par-y 'direction))
                   (new-stencil (ly:stencil-aligned-to
                     (ly:stencil-combine-at-edge
                       (ly:stencil-aligned-to stencil X CENTER)
                       Y dir
                       (ly:stencil-aligned-to
                         (grob-interpret-markup grob text) X CENTER))
                     X LEFT))
                   (staff-space (ly:output-def-lookup
                     (ly:grob-layout grob) 'staff-space))
                   (staff-line-thickness
                     (ly:output-def-lookup (ly:grob-layout grob) 'line-thickness))
                   (par-x (ly:grob-parent grob X))
                   (dyn-text (grob::has-interface par-x 'dynamic-text-interface))
                   (dyn-text-stencil-x-length
                     (if dyn-text
                       (interval-length
                         (ly:stencil-extent (ly:grob-property par-x 'stencil) X))
                       0))
                   (x-shift
                     (if dyn-text
                       (-
                         (+ staff-space dyn-text-stencil-x-length)
                         (* 0.5 staff-line-thickness)) 0)))

            (ly:grob-set-property! grob 'Y-offset 0)
            (ly:grob-set-property! grob 'stencil
               (ly:stencil-translate-axis
                new-stencil
                x-shift X))))
      #})

    hairpinMolto =
    \hairpinWithCenteredText \markup { \italic molto }

    hairpinMore =
    \hairpinWithCenteredText \markup { \larger moltissimo }

    \layout { ragged-right = ##f }

    \relative c' {
      \hairpinMolto
      c2\< c\f
      \hairpinMore
      c2\ppppp\< c\f
      \break
      \hairpinMolto
      c2^\< c\f
      \hairpinMore
      c2\ppppp\< c\f
    }

## Changing ottava text

Internally, `\ottava` sets the properties `ottavation` (for example, to `8va` or `8vb`) and `middleCPosition`. To override the text of the bracket, set `ottavation` after invoking `\ottava`.

Short text is especially useful when a brief ottava is used.

    {
      c'2
      \ottava #1
      \set Staff.ottavation = #"8"
      c''2
      \ottava #0
      c'1
      \ottava #1
      \set Staff.ottavation = #"Text"
      c''1
    }

## Changing the default text font family

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
         to show all fonts available in the process log.
      %}

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

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

## Combining dynamics with markup texts

Some dynamics may involve text indications (such as “più forte” or “piano subito”). These can be produced using a `\markup` block.

    piuF = \markup { \italic più \dynamic f }

    \layout { ragged-right = ##f }

    \relative c'' {
      c2\f c-\piuF
    }

## Combinare due parti sullo stesso rigo

Lo strumento di unione delle parti (il comando `\partCombine`) permette di combinare varie parti sullo stesso rigo. Indicazioni testuali come “solo” e “a2” sono aggiunte automaticamente; per toglierele basta impostare la proprietà `printPartCombineTexts` su `f`. Per le partiture vocali (inni), non c’è bisogno di aggiungere i testi “solo/a2”, quindi dovrebbero essere disattivati. Tuttavia potrebbe convenire non usarlo se c’è una qualche parte solista, perché non verrebbe indicata. In tali casi è preferibile usare la notazione polifonica normale.

Questo frammento illustra i tre modi con cui due parti possono essere stampate su uno stesso rigo: normale polifonia, `\partCombine` senza testo e `\partCombine` con testo.

    %% Combining pedal notes with clef changes

    musicUp = \relative c'' {
      \time 4/4
      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 \stemDown a
    }

    \score {
        <<
        \new Staff \with { instrumentName = "Standard polyphony" }

          << \musicUp \\ \musicDown >>

        \new Staff \with {
          instrumentName = "PartCombine without text"
          printPartCombineTexts = ##f
        }

        \partCombine \musicUp \musicDown

        \new Staff \with { instrumentName = "PartCombine with text" }
          \partCombine \musicUp \musicDown
        >>
      \layout {
        indent = 6.0\cm
        \context {
          \Score
          \override SystemStartBar.collapse-height = #30
        }
      }
    }

## Creating "real" parenthesized dynamics

Although the easiest way to add parentheses 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 the Notation Reference), 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`.

    paren =
    #(define-event-function (dyn) (ly:event?)
       (make-dynamic-script
        #{ \markup \concat {
             \normal-text \italic \fontsize #2 (
    	 \pad-x #0.2 #(ly:music-property dyn 'text)
    	 \normal-text \italic \fontsize #2 )
           }
        #}))

    \relative c'' {
      c4\paren\f c c \dynamicUp c\paren\p
    }

## Creating simultaneous rehearsal marks

Unlike text scripts, rehearsal marks cannot be stacked at a particular point in a score: only one `RehearsalMark` object is created. Using an invisible measure and bar line, an extra rehearsal mark can be added, giving the appearance of two marks in the same column.

This method may also prove useful for placing rehearsal marks at both the end of one system and the start of the following system.

    {
      \key a \major
      \set Score.markFormatter = #format-mark-box-letters
      \once \override Score.RehearsalMark.outside-staff-priority = #5000
      \once \override Score.RehearsalMark.self-alignment-X = #LEFT
      \once \override Score.RehearsalMark.break-align-symbols = #'(key-signature)
      \mark \markup { \bold { Senza denti } }

      % the hidden measure and bar line
      % \cadenzaOn turns off automatic calculation of bar numbers
      \cadenzaOn
      \once \override Score.TimeSignature.stencil = ##f
      \time 1/16
      s16 \bar ""
      \cadenzaOff

      \time 4/4
      \once \override Score.RehearsalMark.self-alignment-X = #LEFT
      \mark \markup { \box \bold Intro }
      d'1
      \mark \default
      d'1
    }

## Creating text spanners

The `\startTextSpan` and `\stopTextSpan` commands allow the creation of text spanners as easily as pedal indications or octavations. Override some properties of the `TextSpanner` object to modify its output.

    \paper { ragged-right = ##f }

    \relative c'' {
      \override TextSpanner.bound-details.left.text = #"bla"
      \override TextSpanner.bound-details.right.text = #"blu"
      a4 \startTextSpan
      b4 c
      a4 \stopTextSpan

      \override TextSpanner.style = #'line
      \once \override TextSpanner.bound-details.left.stencil-align-dir-y = #CENTER
      a4 \startTextSpan
      b4 c
      a4 \stopTextSpan

      \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) }
      \once \override TextSpanner.bound-details.right.padding = #-2

      a4 \startTextSpan
      b4 c
      a4 \stopTextSpan

      \set Staff.middleCPosition = #-13
      \override TextSpanner.dash-period = #10
      \override TextSpanner.dash-fraction = #0.5
      \override TextSpanner.thickness = #10
      a4 \startTextSpan
      b4 c
      a4 \stopTextSpan
    }

## Demonstrating all headers

All header fields with special meanings.

    \header {
      copyright = "copyright"
      title = "title"
      subtitle = "subtitle"
      composer = "composer"
      arranger = "arranger"
      instrument = "instrument"
      metre = "metre"
      opus = "opus"
      piece = "piece"
      poet = "poet"
      texidoc = "All header fields with special meanings."
      copyright = "public domain"
      enteredby = "jcn"
      source = "urtext"
    }

    \layout {
      ragged-right = ##f
    }

    \score {
      \relative c'' { c1 | c | c | c }
    }

    \score {
       \relative c'' { c1 | c | c | c }
       \header {
         title = "localtitle"
         subtitle = "localsubtitle"
         composer = "localcomposer"
         arranger = "localarranger"
         instrument = "localinstrument"
         metre = "localmetre"
         opus = "localopus"
         piece = "localpiece"
         poet = "localpoet"
         copyright = "localcopyright"
       }
    }

## Embedding native PostScript in a \markup block

PostScript code can be directly inserted inside a `\markup` block.

    % PostScript is a registered trademark of Adobe Systems Inc.

    \relative c'' {
      a4-\markup { \postscript "3 4 moveto 5 3 rlineto stroke" }
      -\markup { \postscript "[ 0 1 ] 0 setdash 3 5 moveto 5 -3 rlineto stroke " }

      b4-\markup { \postscript "3 4 moveto 0 0 1 2 8 4 20 3.5 rcurveto stroke" }
      s2
      a'1
    }

## Formattazione delle sillabe del testo vocale

La modalità markup può essere usata per formattare le singole sillabe del testo vocale.

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

    <<
      \new Voice = melody \mel
      \new Lyrics \lyricsto melody \lyr
    >>

## How to put ties between syllables in lyrics

This can be achieved by separating those syllables by tildes.

    \lyrics {
      wa~o~a
    }

## Allineamento del testo vocale

L’allineamento orizzontale del testo vocale si imposta attraverso la proprietà `self-alignment-X` dell’oggetto `LyricText`. `#-1` è sinistra, `#0` è centro e `#1` è destra; si possono usare anche `#LEFT`, `#CENTER` e `#RIGHT`.

    \layout { ragged-right = ##f }
    \relative c'' {
      c1
      c1
      c1
    }
    \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"
    }

## Markup list

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

    %% updated/modified by P.P.Schneider on Feb. 2014

    #(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
    \markuplist {
      \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
          \concat { simple \hspace #.3 ; }
          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.
        }
        \vspace #.3
        \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
          \concat { besoin \hspace #.3 ; }
          ses palefreniers étaient ses
          \concat { piqueurs \hspace #.3 ; }
          le vicaire du village était
          son grand-aumônier.  Ils l'appelaient tous monseigneur, et ils
          riaient quand il faisait des contes.
        }
      }
    }

## Testo a margine delle pause multiple

Il testo a margine di una pausa multipla viene centrato sopra o sotto di essa. Se il testo è lungo, la misura non si espanderà. Per espandere la pausa multipla in modo che si allinei col testo, conviene usare un accordo vuoto con del testo attaccato prima della pausa multipla.

Il testo così attaccato a una nota spaziatrice viene allineato a sinistra della posizione in cui la nota sarebbe posta nella misura, ma se la lunghezza della misura è determinata dalla lunghezza del testo, il testo verrà centrato.

    \relative c' {
      \compressMMRests {
        \textLengthOn
        <>^\markup { [MAJOR GENERAL] }
        R1*19
        <>_\markup { \italic { Cue: ... it is yours } }
        <>^\markup { A }
        R1*30^\markup { [MABEL] }
        \textLengthOff
        c4^\markup { CHORUS } d f c
      }
    }

## Of the ubiquity of markup objects

Text objects are entered either as simple strings between double quotes or as `\markup` blocks that can accept a variety of advanced text formatting and graphical enhancements.

As such, markup blocks may be used:

- in any TextScript object (attached to notes with `-`, `^` or `_`),
- any RehearsalMark introduced with the `\mark` keyword, or other similar objects such as MetronomeMark introduced with `\tempo`,
- as standalone markup blocks, entered at the top level outside of any `\score` block,
- in any definition inside the `\header` block (e.g. title, subtitle, composer) or in some variables defined inside the `\paper` block such as `evenHeaderMarkup` for page numbers.

`\markup` may additionally be used for lyrics, in chord names, and as dynamics. In fact, it is possible to use `\markup` to customize the appearance of virtually any object, as demonstrated in this example using various methods.

    %% Thanks to Aaron Hill https://lists.gnu.org/archive/html/lilypond-user/2019-01/msg00437.html

    \paper {
      paper-width = 8\cm paper-height = 8\cm
    }
    \header {
      title = \markup "Header"
      tagline = \markup "(tagline)"
    }
    \markup "Top-level markup"
    dyn = #(make-dynamic-script #{ \markup \text "DynamicText" #})
    \score {
      <<
        \new ChordNames
        \with { majorSevenSymbol = \markup "majorSevenSymbol" }
        \chordmode { c1:maj7 }
        \new Staff {
          \tempo \markup "MetronomeMark"
          \mark \markup "RehearsalMark"
          \once \override TupletNumber.text = \markup "TupletNumber"
          \tuplet 3/2 {
            \once \override NoteHead.stencil = #ly:text-interface::print
            \once \override NoteHead.text = \markup \lower #0.5 "NoteHead"
            c''8^\markup "TextScript"
            \once \override Rest.stencil = #(lambda (grob)
              (grob-interpret-markup grob #{
                \markup  "Rest"
                #}))
            r4
          }
        }
        \new Lyrics \lyricmode { \markup "LyricText" 1 }
        \new Dynamics { s1\dyn }
      >>
    }

## Outputting the version number

By putting the output of `lilypond-version` into a lyric, it is possible to print the version number of LilyPond in a score, or in a document generated with `lilypond-book`. Another possibility is to append the version number to the doc-string, in this manner:

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

## Modello per pianoforte con testo al centro

Invece di destinare un rigo a parte alla linea melodica e al suo testo, è possibile collocare il testo al centro di un doppio pentagramma per pianoforte.

    upper = \relative c'' {
      \clef treble
      \key c \major
      \time 4/4

      a4 b c d
    }

    lower = \relative c {
      \clef bass
      \key c \major
      \time 4/4

      a2 c
    }

    text = \lyricmode {
      Aaa Bee Cee Dee
    }

    \score {
      \new PianoStaff <<
        \new Staff = upper { \new Voice = "singer" \upper }
        \new Lyrics \lyricsto "singer" \text
        \new Staff = lower { \lower }
      >>
      \layout { }
      \midi { }
    }

## Stampare i numeri di battuta a intervalli regolari variabili

L’intervallo dei numeri di battuta può essere modificato cambiando la funzione di contesto `{set-bar-number-visibility}`.

    \relative c' {
      \override Score.BarNumber.break-visibility = #end-of-line-invisible
      \context Score \applyContext #(set-bar-number-visibility 4)
      \repeat unfold 10 c'1
      \context Score \applyContext #(set-bar-number-visibility 2)
      \repeat unfold 10 c
    }

## Posizionare le indicazioni alla fine di una linea

È possibile posizionare le indicazioni alla fine della linea corrente, invece che all’inizio della linea successiva. In tali casi, può essere preferibile allineare l’estremità destra dell’indicazione alla stanghetta.

    \relative c'' {
      g2 c
      d,2 a'
      \once \override Score.RehearsalMark.break-visibility =
        #end-of-line-visible
      \once \override Score.RehearsalMark.self-alignment-X =
        #RIGHT
      \mark "D.C. al Fine"
      \break
      g2 b,
      c1 \bar "||"
    }

## Stampare le indicazioni su ogni rigo

Sebbene le indicazioni testuali siano di norma collocate solo sopra il rigo più alto, è possibile farle apparire su ogni rigo.

    \score {
      <<
        \new Staff { c''1 \mark "molto" c'' }
        \new Staff { c'1 \mark "molto" c' }
      >>
      \layout {
        \context {
          \Score
          \remove "Mark_engraver"
          \remove "Staff_collecting_engraver"
        }
        \context {
          \Staff
          \consists "Mark_engraver"
          \consists "Staff_collecting_engraver"
        }
      }
    }

## Printing text from right to left

It is possible to print text from right to left in a markup object, as demonstrated here.

    {
      b1^\markup {
        \line { i n g i r u m i m u s n o c t e }
      }
      f'_\markup {
        \override #'(text-direction . -1)
        \line { i n g i r u m i m u s n o c t e }
      }
    }

## Putting lyrics inside the staff

Lyrics can be moved vertically to place them inside the staff. The lyrics are moved with `\override LyricText.extra-offset = #'(0 . dy)` and there are similar commands to move the extenders and hyphens. The offset needed is established with trial and error.

    <<
      \new Staff <<
        \new Voice = "voc" \relative c' { \stemDown a bes c8 b c4 }
      >>
      \new Lyrics \with {
        \override LyricText.extra-offset = #'(0 . 8.6)
        \override LyricExtender.extra-offset = #'(0 . 8.6)
        \override LyricHyphen.extra-offset = #'(0 . 8.6)
      } \lyricsto "voc" { La la -- la __ _ la }
    >>

## Testo separato su due colonne

Il testo separato può essere disposto su varie colonne con i comandi di `\markup`:

    \markup {
      \fill-line {
        \hspace #1
        \column {
          \line { O sacrum convivium }
          \line { in quo Christus sumitur, }
          \line { recolitur memoria passionis ejus, }
          \line { mens impletur gratia, }
          \line { futurae gloriae nobis pignus datur. }
          \line { Amen. }
        }
        \hspace #2
        \column \italic {
          \line { O sacred feast }
          \line { in which Christ is received, }
          \line { the memory of His Passion is renewed, }
          \line { the mind is filled with grace, }
          \line { and a pledge of future glory is given to us. }
          \line { Amen. }
        }
        \hspace #1
      }
    }

## String number extender lines

Make an extender line for string number indications, showing that a series of notes is supposed to be played all on the same string.

    stringNumberSpanner =
      #(define-music-function (StringNumber) (string?)
        #{
          \override TextSpanner.style = #'solid
          \override TextSpanner.font-size = #-5
          \override TextSpanner.bound-details.left.stencil-align-dir-y = #CENTER
          \override TextSpanner.bound-details.left.text =
            \markup { \circle \number $StringNumber }
        #})

    \relative c {
      \clef "treble_8"
      \stringNumberSpanner "5"
      \textSpannerDown
      a8\startTextSpan
      b c d e f\stopTextSpan
      \stringNumberSpanner "4"
      g\startTextSpan a
      bes4 a g2\stopTextSpan
    }

## Three-sided box

This example shows how to add a markup command to get a three sided box around some text (or other markup).

    % New command to add a three sided box, with sides north, west and south
    % Based on the box-stencil command defined in scm/stencil.scm
    % Note that ";;" is used to comment a line in Scheme
    #(define-public (NWS-box-stencil stencil thickness padding)
       "Add a box around STENCIL, producing a new stencil."
       (let* ((x-ext (interval-widen (ly:stencil-extent stencil X) padding))
              (y-ext (interval-widen (ly:stencil-extent stencil Y) padding))
              (y-rule (make-filled-box-stencil (cons 0 thickness) y-ext))
              (x-rule (make-filled-box-stencil
                       (interval-widen x-ext thickness) (cons 0 thickness))))
         ;; (set! stencil (ly:stencil-combine-at-edge stencil X 1 y-rule padding))
         (set! stencil (ly:stencil-combine-at-edge stencil X LEFT y-rule padding))
         (set! stencil (ly:stencil-combine-at-edge stencil Y UP x-rule 0.0))
         (set! stencil (ly:stencil-combine-at-edge stencil Y DOWN x-rule 0.0))
         stencil))

    % The corresponding markup command, based on the \box command defined
    % in scm/define-markup-commands.scm
    #(define-markup-command (NWS-box layout props arg) (markup?)
       #:properties ((thickness 0.1) (font-size 0) (box-padding 0.2))
       "Draw a box round @var{arg}.  Looks at @code{thickness},
    @code{box-padding} and @code{font-size} properties to determine line
    thickness and padding around the markup."
       (let ((pad (* (magstep font-size) box-padding))
             (m (interpret-markup layout props arg)))
         (NWS-box-stencil m thickness pad)))

    % Test it:

    \relative c' {
      c1^\markup { \NWS-box ABCD }
      c1^\markup { \NWS-box \note {4} #1.0 }
    }

## UTF-8

Various scripts may be used for texts (like titles and lyrics) 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

    %% Edit this file using a Unicode aware editor, such as GVIM, GEDIT, Emacs

    %{

    You may have to install additional fonts.

    Red Hat Fedora

    	linux-libertine-fonts (Latin, Cyrillic, Hebrew)
    	ipa-mincho-fonts ipa-gothic-fonts (Japanese)

    Debian GNU/Linux, Ubuntu

    	fonts-linuxlibertine (Latin, Cyrillic, Hebrew)
    	fonts-ipafont (Japanese)

    %}

    % Font settings for Cyrillic and Hebrew
    % Linux Libertine fonts contain Cyrillic and Hebrew glyphs.
    \paper {
      #(define fonts
        (set-global-fonts
         #:roman "Linux Libertine O,serif"
         #:sans "Linux Biolinum O,sans-serif"
         #:typewriter "Linux Libertine Mono O,monospace"
       ))
    }

    % Cyrillic font
    bulgarian = \lyricmode {
      Жълтата дюля беше щастлива, че пухът, който цъфна, замръзна като гьон.
    }

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

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

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

    \relative c' {
      c2 d
      e2 f
      g2 f
      e1
    }
    \addlyrics { \bulgarian }
    \addlyrics { \hebrew }
    \addlyrics { \japanese }
    \addlyrics { \portuguese }

## Modello per gruppo vocale con testo allineato sotto e sopra i righi

Questo modello è fondamentalmente analogo al semplice modello “Complesso vocale”, con l’unica differenza che qui tutti i versi del testo sono posizionati usando `alignAboveContext` e `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
      >>
    }

## Volta text markup using repeatCommands

Though volte are best specified using `\repeat volta`, the context property `repeatCommands` must be used in cases where the volta text needs more advanced formatting with `\markup`.

Since `repeatCommands` takes a list, the simplest method of including markup is to use an identifier for the text and embed it in the command list using the Scheme syntax `#(list (list 'volta textIdentifier))`. Start- and end-repeat commands can be added as separate list elements:

    voltaAdLib = \markup { 1. 2. 3... \text \italic { ad lib. } }

    \relative c'' {
      c1
      \set Score.repeatCommands = #(list (list 'volta voltaAdLib) 'start-repeat)
      c4 b d e
      \set Score.repeatCommands = #'((volta #f) (volta "4.") end-repeat)
      f1
      \set Score.repeatCommands = #'((volta #f))
    }

#### LilyPond — Frammenti v2.22.2 (ramo stabile).