1.8.1 Writing text

This section introduces different ways of adding text to a score.

Nota: To write accented and special text (such as characters from other languages), simply insert the characters directly into the LilyPond file. The file must be saved as UTF-8. For more information, see Text encoding.


Text scripts

Simple “quoted text” indications may be added to a score, as demonstrated in the following example. Such indications may be manually placed above or below the staff, using the syntax described in Direction and placement.

\relative { a'8^"pizz." g f e a4-"scherz." f }

[image of music]

This syntax is actually a shorthand; more complex text formatting may be added to a note by explicitly using a \markup block, as described in Formatting text.

\relative {
  a'8^\markup { \italic pizz. } g f e
  a4_\markup { \tiny scherz. \bold molto } f }

[image of music]

By default, text indications do not influence the note spacing. However, their widths can be taken into account: in the following example, the first text string does not affect spacing, whereas the second one does.

\relative {
  a'8^"pizz." g f e
  \textLengthOn
  a4_"scherzando" f
}

[image of music]

In addition to text scripts, articulations can be attached to notes. For more information, see Articulacions i ornaments.

For more information about the relative ordering of text scripts and articulations, see Placement of objects.

Instruccions predefinides

\textLengthOn, \textLengthOff.

Vegeu també

Learning Manual: Placement of objects.

Notation Reference: Formatting text, Direction and placement, Articulacions i ornaments.

Snippets: Text.

Internals Reference: TextScript.

Advertiments i problemes coneguts

Checking to make sure that text scripts and lyrics are within the margins requires additional calculations. In cases where slightly faster performance is desired, use

\override Score.PaperColumn.keep-inside-line = ##f

Text spanners

Some performance indications, e.g., rallentando or accelerando, are written as text and are extended over multiple notes with dotted lines. Such objects, called “spanners”, may be created from one note to another using the following syntax:

\relative {
  \override TextSpanner.bound-details.left.text = "rit."
  b'1\startTextSpan
  e,\stopTextSpan
}

[image of music]

The string to be printed is set through object properties. By default it is printed in italic characters, but different formatting can be obtained using \markup blocks, as described in Formatting text.

\relative {
  \override TextSpanner.bound-details.left.text =
    \markup { \upright "rit." }
  b'1\startTextSpan c
  e,\stopTextSpan
}

[image of music]

The line style, as well as the text string, can be defined as an object property. This syntax is described in Line styles.

Instruccions predefinides

\textSpannerUp, \textSpannerDown, \textSpannerNeutral.

Advertiments i problemes coneguts

LilyPond is only able to handle one text spanner per voice.

Fragments de codi seleccionats

Dynamics text spanner postfix

Custom text spanners can be defined and used with hairpin and text crescendos. \< and \> produce hairpins by default, \cresc etc. produce text spanners by default.

% Some sample text dynamic spanners, to be used as postfix operators
crpoco =
#(make-music 'CrescendoEvent
             'span-direction START
             'span-type 'text
             'span-text "cresc. poco a poco")

\relative c' {
  c4\cresc d4 e4 f4 |
  g4 a4\! b4\crpoco c4 |
  c4 d4 e4 f4 |
  g4 a4\! b4\< c4 |
  g4\dim a4 b4\decresc c4\!
}

[image of music]

Dynamics custom text spanner postfix

Postfix functions for custom crescendo text spanners. The spanners should start on the first note of the measure. One has to use -\mycresc, otherwise the spanner start will rather be assigned to the next note.

% Two functions for (de)crescendo spanners where you can explicitly give the
% spanner text.
mycresc =
#(define-music-function (mymarkup) (markup?)
   (make-music 'CrescendoEvent
               'span-direction START
               'span-type 'text
               'span-text mymarkup))
mydecresc =
#(define-music-function (mymarkup) (markup?)
   (make-music 'DecrescendoEvent
               'span-direction START
               'span-type 'text
               'span-text mymarkup))

\relative c' {
  c4-\mycresc "custom cresc" c4 c4 c4 |
  c4 c4 c4 c4 |
  c4-\mydecresc "custom decresc" c4 c4 c4 |
  c4 c4\! c4 c4
}

[image of music]

Vegeu també

Notation Reference: Line styles, Matisos dinàmics, Formatting text.

Snippets: Text, Expressive marks.

Internals Reference: TextSpanner.


Text marks

Various text elements may be added to a score using the syntax described in Marques d’assaig:

\relative {
  \mark "Verse"
  c'2 g'
  \bar "||"
  \mark "Chorus"
  g2 c,
  \bar "|."
}

[image of music]

This syntax makes it possible to put any text on a bar line; more complex text formatting may be added using a \markup block, as described in Formatting text:

\relative {
  <c' e>1
  \mark \markup { \italic { colla parte } }
  <d f>2 <e g>
  <c f aes>1
}

[image of music]

This syntax also allows to print special signs, like coda, segno or fermata, by specifying the appropriate symbol name as explained in Music notation inside markup:

\relative {
  <bes' f>2 <aes d>
  \mark \markup { \musicglyph #"scripts.ufermata" }
  <e g>1
}

[image of music]

Such objects are only typeset above the top staff of the score; depending on whether they are specified at the end or the middle of a bar, they can be placed above the bar line or between notes. When specified at a line break, the mark will be printed at the beginning of the next line.

\relative c'' {
  \mark "Allegro"
  c1 c
  \mark "assai" \break
  c  c
}

[image of music]

Instruccions predefinides

\markLengthOn, \markLengthOff.

Fragments de codi seleccionats

Printing marks at the end of a line

Marks can be printed at the end of the current line, instead of the beginning of the following line. In such cases, it might be preferable to align the right end of the mark with the bar line.

\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 "||"
}

[image of music]

Printing marks on every staff

Although text marks are normally only printed above the topmost staff, they may also be printed on every staff.

\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"
    }
  }
}

[image of music]

Vegeu també

Notation Reference: Marques d’assaig, Formatting text, Music notation inside markup, The Emmentaler font.

Snippets: Text.

Internals Reference: MarkEvent, Mark_engraver, RehearsalMark.


Separate text

A \markup block can exist by itself, outside of any \score block, as a “top-level expression”. This syntax is described in File structure.

\markup {
  Tomorrow, and tomorrow, and tomorrow...
}

[image of music]

This allows printing text separately from the music, which is particularly useful when the input file contains several music pieces, as described in Multiple scores in a book.

\score {
  c'1
}
\markup {
  Tomorrow, and tomorrow, and tomorrow...
}
\score {
  c'1
}

[image of music]

Separate text blocks can be spread over multiple pages, making it possible to print text documents or books entirely within LilyPond. This feature, and the specific syntax it requires, are described in Multi-page markup.

Instruccions predefinides

\markup, \markuplist.

Fragments de codi seleccionats

Stand-alone two-column markup

Stand-alone text may be arranged in several columns using \markup commands:

\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
  }
}

[image of music]

Vegeu també

Notation Reference: Formatting text, File structure, Multiple scores in a book, Multi-page markup.

Snippets: Text.

Internals Reference: TextScript.


Altres idiomes: English, deutsch, español, français, italiano, 日本語.
Quant a la selecció automàtica de la llengua.

LilyPond — Referència de la notació v2.21.0 (branca de desenvolupament).