2.5.1 Markup construction in Scheme

Markup expressions are internally represented in Scheme using the markup macro:

(markup expr)

To see a markup expression in its Scheme form, use the \displayScheme command:

\displayScheme
\markup {
  \column {
    \line { \bold \italic "hello" \raise #0.4 "world" }
    \larger \line { foo bar baz }
  }
}

Compiling the code above will send the following to the display console:

(markup
  #:line
  (#:column
   (#:line
    (#:bold (#:italic "hello") #:raise 0.4 "world")
    #:larger
    (#:line ("foo" "bar" "baz")))))

To prevent the markup from printing on the page, use ‘\void \displayScheme markup. Also, as with the \displayMusic command, the output of \displayScheme can be saved to an external file. See Displaying music expressions.

This example demonstrates the main translation rules between regular LilyPond markup syntax and Scheme markup syntax. Using #{ … #} for entering in LilyPond syntax will often be most convenient, but we explain how to use the markup macro to get a Scheme-only solution.

LilyPondScheme
\markup markup1(markup markup1)
\markup { markup1 markup2 … }(markup markup1 markup2 …)
\markup-command#:markup-command
\variablevariable
\center-column { … }#:center-column (…)
string"string"
#scheme-argscheme-arg

The whole Scheme language is accessible inside the markup macro. For example, You may use function calls inside markup in order to manipulate character strings. This is useful when defining new markup commands (see New markup command definition).

Known issues and warnings

The markup-list argument of commands such as #:line, #:center, and #:column cannot be a variable or the result of a function call.

(markup #:line (function-that-returns-markups))

is invalid. One should use the make-line-markup, make-center-markup, or make-column-markup functions instead,

(markup (make-line-markup (function-that-returns-markups)))

Extending LilyPond v2.25.20 (development-branch).