Next: , Previous: Fonts, Up: Changing defaults



7.4 Text markup

The internal mechanism to typeset texts is accessed with the keyword \markup. Within markup mode, you can enter texts similar to lyrics. They are simply entered, while commands use the backslash \.

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

     {
       c'^\markup { \raise #0.5 not-raised }
       c'^\markup { "" \raise #0.5 raised }
     }

[image of music]

On the second note, the text raised is moved 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

No kerning or generation of ligatures is only done when the by 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.

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

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

Other languages: English.
Using automatic language selection.