Next: , Previous: Fonts, Up: Changing defaults



4.5 Text markup

LilyPond has an internal mechanism to typeset texts. You can access it with the keyword \markup. Within markup mode, you can enter texts similar to lyrics: simply enter them, surrounded by spaces:

 c1^\markup { hello }
 c1_\markup { hi there }
 c1^\markup { hi \bold there, is \italic anyone home? }

[image of music]

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

       \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. The braces group notes into horizontal lines. Other types of lists also exist: you can stack expressions grouped with < and > vertically with the command \column. Similarly, \center-align aligns texts by their center lines:

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

[image of music]

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

allegro = \markup { \bold \large { Allegro } }
\notes { 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.

Similarly, for moving whole texts over notes with \raise, use the following trick:

       "" \raise #0.5 raised

The text raised is now raised relative to the empty string "" which is not visible. Alternatively, complete objects can be moved with layout properties such as padding and extra-offset.

See also

Init files: scm/new-markup.scm.

Bugs

Text layout is ultimately done by TeX, which does kerning of letters. LilyPond does not account for kerning, so texts will be spaced slightly too wide.

Syntax errors for markup mode are confusing.

Markup texts cannot be used in the titling of the \header field. Titles are made by LaTeX, so LaTeX commands should be used for formatting.

Read comments on this page, or add one.

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

Report errors to <bug-lilypond@gnu.org>.