GNU LilyPond Notation Reference: 1.8.1 Writing text

### 1.8.1 Writing text

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

Note: 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.

>     a8^"pizz." g f e a4-"scherz." f

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.

>     a8^\markup { \italic pizz. } g f e
>     a4_\markup { \tiny scherz. \bold molto } f

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.

>     a8^"pizz." g f e
>     \textLengthOn
>     a4_"scherzando" f

#### Predefined commands

`\textLengthOn`, `\textLengthOff`.

#### See also

Notation Reference: Formatting text, Direction and placement.

Snippets: Text.

Internals Reference: TextScript.

#### Known issues and warnings

Checking to make sure that text scripts and lyrics are within the margins is a relatively large computational task. To speed up processing, LilyPond does not perform such calculations by default; to enable it, use

>     \override Score.PaperColumn #'keep-inside-line = ##t

#### 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:

>     \override TextSpanner #'(bound-details left text) = "rit."
>     b1\startTextSpan
>     e,\stopTextSpan

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.

>     \override TextSpanner #'(bound-details left text) =
>       \markup { \upright "rit." }
>     b1\startTextSpan c
>     e,\stopTextSpan

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

#### Predefined commands

`\textSpannerUp`, `\textSpannerDown`, `\textSpannerNeutral`.

#### See also

Notation Reference: Line styles, Dynamics.

Snippets: Text.

Internals Reference: TextSpanner.

#### Text marks

Various text elements may be added to a score using the syntax described in Rehearsal marks:

>     c4
>     \mark "Allegro"
>     c c c

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:

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

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:

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

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.

>     \mark "Allegro"
>     c1 c
>     \mark "assai" \break
>     c  c

#### Selected Snippets

Printing marks at the end of a line or a score

Marks can be printed at the end of the current line, instead of the beginning of the following line. This is particularly useful when a mark has to be added at the end of a score – when there is no next line.

In such cases, the right end of the mark has to be aligned with the final bar line, as demonstrated on the second line of this example.

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

Aligning marks with various notation objects

If specified, text marks may be aligned with notation objects other than bar lines. These objects include `ambitus`, `breathing-sign`, `clef`, `custos`, `staff-bar`, `left-edge`, `key-cancellation`, `key-signature`, and `time-signature`.

In such cases, text marks will be horizontally centered above the object. However this can be changed, as demonstrated on the second line of this example (in a score with multiple staves, this setting should be done for all the staves).

>     \relative c' {
>       e1

>       % the RehearsalMark will be centered above the Clef
>       \override Score.RehearsalMark #'break-align-symbols = #'(clef)
>       \key a \major
>       \clef treble
>       \mark "↓"
>       e1

>       % the RehearsalMark will be centered above the TimeSignature
>       \override Score.RehearsalMark #'break-align-symbols = #'(time-signature)
>       \key a \major
>       \clef treble
>       \time 3/4
>       \mark "↓"
>       e2.

>       % the RehearsalMark will be centered above the KeySignature
>       \override Score.RehearsalMark #'break-align-symbols = #'(key-signature)
>       \key a \major
>       \clef treble
>       \time 4/4
>       \mark "↓"
>       e1

>       \break
>       e1

>       % the RehearsalMark will be aligned with the left edge of the KeySignature
>       \once \override Score.KeySignature #'break-align-anchor-alignment = #LEFT
>       \mark "↓"
>       \key a \major
>       e1

>       % the RehearsalMark will be aligned with the right edge of the KeySignature
>       \once \override Score.KeySignature #'break-align-anchor-alignment = #RIGHT
>       \key a \major
>       \mark "↓"
>       e1

>       % the RehearsalMark will be aligned with the left edge of the KeySignature
>       % and then shifted right by one unit.
>       \once \override Score.KeySignature #'break-align-anchor = #1
>       \key a \major
>       \mark "↓"
>       e1
>     }

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

#### See also

Notation Reference: Rehearsal marks, Formatting text, Music notation inside markup, The Feta font.

Snippets: Text.

Internals Reference: RehearsalMark.

#### Known issues and warnings

If a mark is entered at the end of the last bar of the score (where there is no next line), then the mark will not be printed at all.

#### Separate text

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

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

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

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.

#### Predefined commands

`\markup`, `\markuplines`.

#### Selected Snippets

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 {
>           \line { \italic { O sacred feast } }
>           \line { \italic { in which Christ is received, } }
>           \line { \italic { the memory of His Passion is renewed, } }
>           \line { \italic { the mind is filled with grace, } }
>           \line { \italic { and a pledge of future glory is given to us. } }
>           \line { \italic { Amen. } }
>         }
>         \hspace #1
>       }
>     }

#### See also

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

Snippets: Text.

Internals Reference: TextScript.

Other languages: français, español, deutsch.

#### Notation Reference