Next: , Previous: Text marks, Up: Text


8.1.4 Text markup

Use \markup to typeset text. Commands are entered with the backslash \. To enter \ and #, use double quotation marks.

     
     c1^\markup { hello }
     c1_\markup { hi there }
     c1^\markup { hi \bold there, is \italic {anyone home?} }
     c1_\markup { "\special {weird} #characters" }

[image of music]

See Overview of text markup commands for a list of all commands.

\markup is primarily used for TextScripts, but it can also be used anywhere text is called in lilypond

     
     \header{ title = \markup{ \bold { foo \italic { bar! } } } }
     \score{
       \relative c'' {
         \override Score.RehearsalMark
           #'break-visibility = #begin-of-line-invisible
         \override Score.RehearsalMark #'self-alignment-X = #right
     
         \set Staff.instrumentName = \markup{ \column{ Alto solo } }
         c2^\markup{ don't be \flat }
         \override TextSpanner #'edge-text = #(cons (markup #:italic "rit" ) "")
         b2\startTextSpan
         a2\mark \markup{ \large \bold Fine }
         r2\stopTextSpan
         \bar "||"
       }
       \addlyrics { bar, foo \markup{ \italic bar! } }
     }

[image of music]

A \markup command can also be placed on its own, away from any \score block, see Multiple scores in a book.

     
     \markup{ Here is some text. }

[image of music]

The markup in the example demonstrates font switching commands. The command \bold and \italic apply to the first following word only; to apply a command to more than one word, enclose the words with braces,

\markup { \bold { hi there } }

For clarity, you can also do this for single arguments, e.g.,

\markup { is \italic { anyone } home }

In markup mode you can compose expressions, similar to mathematical expressions, XML documents, and music expressions. You can stack expressions grouped vertically with the command \column. Similarly, \center-align aligns texts by their center lines:

     
     c1^\markup { \column { a bbbb \line { c d } } }
     c1^\markup { \center-align { a bbbb c } }
     c1^\markup { \line { a b c } }

[image of music]

Lists with no previous command are not kept distinct. The expression

\center-align { { a b } { c d } }

is equivalent to

\center-align { a b c d }

To keep lists of words distinct, please use quotes " or the \line command

     
     \fatText
     c4^\markup{ \center-align { on three lines } }
     c4^\markup{ \center-align { "all one line" } }
     c4^\markup{ \center-align { { on three lines } } }
     c4^\markup{ \center-align { \line { on one line } } }

[image of music]

Markups can be stored in variables and these variables may be attached to notes, like

allegro = \markup { \bold \large { Allegro } }
 { a^\allegro b c d }

Some objects have alignment procedures of their own, which cancel out any effects of alignments applied to their markup arguments as a whole. For example, the RehearsalMark is horizontally centered, so using \mark \markup { \left-align .. } has no effect.

In addition, vertical placement is performed after creating the text markup object. If you wish to move an entire piece of markup, you need to use the #'padding property or create an "anchor" point inside the markup (generally with \hspace #0).

     
     \fatText
     c'4^\markup{ \raise #5 "not raised" }
     \once \override TextScript #'padding = #3
     c'4^\markup{ raised }
     c'4^\markup{ \hspace #0 \raise #1.5 raised }

[image of music]

Some situations (such as dynamic marks) have preset font-related properties. If you are creating text in such situations, it is advisable to cancel those properties with normal-text. See Overview of text markup commands for more details.

See also

This manual: Overview of text markup commands.

Program reference: TextScript.

Init files: scm/new-markup.scm.

Bugs

Kerning or generation of ligatures is only done when the TeX backend is used. In this case, LilyPond does not account for them so texts will be spaced slightly too wide.

Syntax errors for markup mode are confusing.


Next: , Previous: Text marks, Up: Text

This page is for LilyPond-2.10.33 (stable-branch).

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