A.10.2 Markup for text alignment

\abs-hspace amount (number)

Create an invisible object taking up absolute horizontal space of amount points.

\markup {
  one
  \abs-hspace #20
  two
  \abs-hspace #40
  three
}

[image of music]

See also \hspace.

\abs-vspace amount (number)

Create an invisible object taking up absolute vertical space of amount points.

\markup {
    \center-column {
    one
    \abs-vspace #20
    two
    \abs-vspace #40
    three
  }
}

[image of music]

See also \vspace.

\align-on-other axis (non-negative, exact integer) other-dir (boolean-or-number) other (markup) self-dir (boolean-or-number) self (markup)

Align markup self on markup other along axis.

This function uses self-dir and other-dir for mutual alignment of self and other, respectively, translating self as requested relative to its surroundings. other is not printed.

If self-dir or other-dir is #f, use the reference point of self or other, respectively.

\markup \column {
  12
  \align-on-other #X #RIGHT 12
                     #LEFT 12345
  \align-on-other #X #RIGHT 123
                     #LEFT \fermata
  123
  \align-on-other #X #RIGHT 123
                     ##f \fermata
}

[image of music]

\center-align arg (markup)

Align arg to its X center.

\markup {
  \column {
    one
    \center-align two
    three
  }
}

[image of music]

\center-column args (markup list)

Put args into a centered column.

See also \column.

\markup {
  \center-column {
    one
    two
    three
  }
}

[image of music]

Used properties:

  • baseline-skip
\column args (markup list)

Stack the markups in args vertically.

The property baseline-skip determines the space between markups in args (to be more precise, the space between the baselines of the markups).

\markup {
  \column {
    one
    two
    three
  }
}

[image of music]

The baseline of the output of \column is the baseline of its first line.

Used properties:

  • baseline-skip
\combine arg1 (markup) arg2 (markup)

Print arg1, then print arg2 on top of it.

Note: \combine cannot take a list of markups enclosed in curly braces as an argument; for this purpose use \overlay instead.

\markup {
  \fontsize #5
  \override #'(thickness . 2)
  \combine
    \draw-line #'(0 . 4)
    \arrow-head #Y #DOWN ##f
}

[image of music]

\concat args (markup list)

Concatenate args in a horizontal line, without spaces in between.

Strings are concatenated on the input level, allowing ligatures. For example, \concat { "f" "i" } is equivalent to "fi".

\markup {
  \concat {
    one two three
  }
}

[image of music]

\dir-column args (markup list)

Make a column of args.

Depending on the setting of the direction layout property, the arguments are stacked upwards or downwards.

\markup {
  \override #`(direction . ,UP)
  \dir-column {
    going up
  }
  \hspace #1
  \dir-column {
    going down
  }
  \hspace #1
  \override #'(direction . 1)
  \dir-column {
    going up
  }
}

[image of music]

The baseline of the output of \dir-column is the baseline of its first line.

Used properties:

  • baseline-skip
  • direction
\fill-line args (markup list)

Put markups args into a horizontal line.

The markups are spaced or flushed to fill the entire line. If there are no arguments, return an empty stencil.

The width of the horizontal line can be modified by overriding the line-width property.

\markup {
  \column {
    \fill-line {
      Words evenly spaced across the page
    }
    \null
    \fill-line {
      \line { Text markups }
      \line {
        \italic { evenly spaced }
      }
      \line { across the page }
    }
    \null
    \override #'(line-width . 50)
    \fill-line {
      Width explicitly specified
    }
  }
}

[image of music]

Used properties:

  • line-width (#f)
  • word-space (0.6)
  • text-direction (1)
\fill-with-pattern space (number) dir (direction) pattern (markup) left (markup) right (markup)

Put left and right at the start and end of a line, respectively, and fill the space inbetween with repeated pattern markups.

Patterns are spaced apart by space and aligned to direction dir. The width of the line is given by the line-width property.

\markup \column {
  "right-aligned:"
  \fill-with-pattern #1 #RIGHT . first right
  \fill-with-pattern #1 #RIGHT . second right
  \null
  "center-aligned:"
  \fill-with-pattern #1.5 #CENTER - left right
  \null
  "left-aligned:"
  \override #'(line-width . 50) {
    \fill-with-pattern #2 #LEFT : left first
    \fill-with-pattern #2 #LEFT : left second
  }
}

[image of music]

Used properties:

  • line-width
  • word-space
\general-align axis (integer) dir (number) arg (markup)

Align arg in axis direction to the dir side.

\markup {
  \column {
    one
    \general-align #X #LEFT two
    three
    \null
    one
    \general-align #X #CENTER two
    three
    \null
    \line {
      one
      \general-align #Y #UP two
      three
    }
    \null
    \line {
      one
      \general-align #Y #3.2 two
      three
    }
  }
}

[image of music]

\halign dir (number) arg (markup)

Print arg with horizontal alignment set to dir.

If dir is -1, arg is left-aligned, while +1 makes it right-aligned. Values inbetween interpolate the alignment accordingly.

\markup {
  \column {
    one
    \halign #LEFT two
    three
    \null
    one
    \halign #CENTER two
    three
    \null
    one
    \halign #RIGHT two
    three
    \null
    one
    \halign #-5 two
    three
  }
}

[image of music]

\hcenter-in length (number) arg (markup)

Center arg horizontally within a box of extending length/2 to the left and right.

\new StaffGroup <<
  \new Staff {
    \set Staff.instrumentName = \markup {
      \hcenter-in #12 Oboe
    }
    c''1
  }
  \new Staff {
    \set Staff.instrumentName = \markup {
      \hcenter-in #12 Bassoon
    }
    \clef tenor
    c'1
  }
>>

[image of music]

\hspace amount (number)

Create an invisible object taking up amount horizontal space.

\markup {
  one
  \hspace #2
  two
  \hspace #8
  three
}

[image of music]

See also \abs-hspace.

\justify args (markup list)

Print args as lines aligned both at the left and the right.

Like \wordwrap, but with lines stretched to justify the margins. Use \override #'(line-width . X) to set the line width; X is the number of staff spaces.

\markup {
  \justify {
    Lorem ipsum dolor sit amet, consectetur adipisicing elit,
    sed do eiusmod tempor incididunt ut labore et dolore
    magna aliqua.  Ut enim ad minim veniam, quis nostrud
    exercitation ullamco laboris nisi ut aliquip ex ea
    commodo consequat.
  }
}

[image of music]

The baseline of the output of \justify is the baseline of its first line.

Used properties:

  • text-direction (1)
  • word-space
  • line-width (#f)
  • baseline-skip
\justify-field symbol (symbol)

Justify the data that has been assigned to symbol.

\header {
  title = "My title"
  myText = "Lorem ipsum dolor sit amet, consectetur
    adipisicing elit, sed do eiusmod tempor incididunt
    ut labore et dolore magna aliqua.  Ut enim ad minim
    veniam, quis nostrud exercitation ullamco laboris
    nisi ut aliquip ex ea commodo consequat."
}

\paper {
  bookTitleMarkup = \markup {
    \column {
      \fill-line { \fromproperty #'header:title }
      \null
      \justify-field #'header:myText
    }
  }
}

\markup {
  \null
}

[image of music]

\justify-line args (markup list)

Put markups args into a horizontal line.

The markups are spread to fill the entire line and separated by equal space. If there are no arguments, return an empty stencil.

The width of the horizontal line can be modified by overriding the line-width property.

\markup {
  \justify-line {
    Constant space between neighboring words
  }
}

[image of music]

Used properties:

  • line-width (#f)
  • word-space (0.6)
  • text-direction (1)
\justify-string arg (string)

Print string arg as lines aligned both at the left and the right.

Paragraphs are indicated by double newlines. Use \override #'(line-width . X) to set the line width; X is the number of staff spaces.

\markup {
  \override #'(line-width . 40)
  \justify-string "Lorem ipsum dolor sit amet, consectetur
      adipisicing elit, sed do eiusmod tempor incididunt ut
      labore et dolore magna aliqua.


      Ut enim ad minim veniam, quis nostrud exercitation
      ullamco laboris nisi ut aliquip ex ea commodo
      consequat.


      Excepteur sint occaecat cupidatat non proident, sunt
      in culpa qui officia deserunt mollit anim id est
      laborum"
}

[image of music]

The baseline of the output of \justify-string is the baseline of its first line.

Used properties:

  • text-direction (1)
  • word-space
  • line-width
  • baseline-skip
\left-align arg (markup)

Align arg on its left edge.

\markup {
  \column {
    one
    \left-align two
    three
  }
}

[image of music]

\left-column args (markup list)

Put args into a left-aligned column.

\markup {
  \left-column {
    one
    two
    three
  }
}

[image of music]

Used properties:

  • baseline-skip
\line args (markup list)

Put args into a horizontal line.

The property word-space determines the space between markups in args. For right-to-left scripts like Hebrew, text-direction should be set to -1.

\markup
  \override #'(word-space . 3)
  \column {
    \line { "A B" "C D" "E F" }
    \override #'(text-direction . -1)
    \line { "A B" "C D" "E F" }
  }

[image of music]

Used properties:

  • text-direction (1)
  • word-space
\lower amount (number) arg (markup)

Lower arg by the distance amount.

A negative amount indicates raising; see also \raise.

The argument to \lower is the vertical displacement amount, measured in (global) staff spaces, which is independent of the markup’s current font size. If you need vertical movement that takes the font size into account, use \translate-scaled instead.

This function is normally used to move one element inside of a markup relative to the other elements. When using it on the whole markup, bear in mind that spacing mechanisms that place the markup itself on the page could cancel this shift. Consider using grob properties such as padding, Y-offset, or extra-offset, or spacing variables such as markup-system-spacing.

\markup {
  one
  \lower #3 two
  three
}

[image of music]

\overlay args (markup list)

Take a list of markups args and combine them.

\markup {
  \fontsize #5
  \override #'(thickness . 2)
  \overlay {
    \draw-line #'(0 . 4)
    \arrow-head #Y #DOWN ##f
    \translate #'(0 . 4) \arrow-head #Y #UP ##f
  }
}

[image of music]

\pad-around amount (number) arg (markup)

Add padding amount all around arg.

Identical to function \pad-markup.

\markup {
  \box {
    default
  }
  \hspace #2
  \box {
    \pad-around #0.5 {
      padded
    }
  }
}

[image of music]

\pad-markup amount (number) arg (markup)

Add padding amount all around arg.

Identical to function \pad-around.

\markup {
  \box {
    default
  }
  \hspace #2
  \box {
    \pad-markup #1 {
      padded
    }
  }
}

[image of music]

\pad-to-box x-ext (pair of numbers) y-ext (pair of numbers) arg (markup)

Make arg take at least x-ext, y-ext space.

\markup {
  \box {
    default
  }
  \hspace #4
  \box {
    \pad-to-box #'(0 . 10) #'(0 . 3) {
      padded
    }
  }
}

[image of music]

\pad-x amount (number) arg (markup)

Add padding amount around arg in the X direction.

\markup {
  \box {
    default
  }
  \hspace #4
  \box {
    \pad-x #2 {
      padded
    }
  }
}

[image of music]

\put-adjacent axis (integer) dir (direction) arg1 (markup) arg2 (markup)

Put arg2 next to arg1 along axis to the dir side, without moving arg1.

\markup \column {
  text
  \put-adjacent #X #LEFT text *
  text
}

[image of music]

\raise amount (number) arg (markup)

Raise arg by the distance amount.

A negative amount indicates lowering, see also \lower.

The argument to \raise is the vertical displacement amount, measured in (global) staff spaces, which is independent of the markup’s current font size. If you need vertical movement that takes the font size into account, use \translate-scaled instead.

This function is normally used to move one element inside of a markup relative to the other elements. When using it on the whole markup, bear in mind that spacing mechanisms that place the markup itself on the page could cancel this shift. Consider using grob properties such as padding, Y-offset, or extra-offset, or spacing variables such as markup-system-spacing.

\markup { C \small \bold \raise #1.0 9/7+ }

[image of music]

\right-align arg (markup)

Align arg on its right edge.

\markup {
  \column {
    one
    \right-align two
    three
  }
}

[image of music]

\right-column args (markup list)

Put args into a right-aligned column.

\markup {
  \right-column {
    one
    two
    three
  }
}

[image of music]

Used properties:

  • baseline-skip
\rotate ang (number) arg (markup)

Rotate arg by ang degrees around its center.

\markup {
  default
  \hspace #2
  \rotate #45
  \line {
    rotated 45°
  }
}

[image of music]

\translate offset (pair of numbers) arg (markup)

Translate arg relative to its surroundings.

offset is a pair of numbers representing the displacement in the X and Y axes. See also \translate-scaled.

This function is normally used to move one element inside of a markup relative to the other elements. When using it on the whole markup, bear in mind that spacing mechanisms that place the markup itself on the page could cancel this shift. Consider using grob properties such as padding, X-offset, Y-offset or extra-offset, or spacing variables such as markup-system-spacing.

\markup {
  *
  \translate #'(2 . 3)
    \line { translated two spaces right, three up }
}

[image of music]

\translate-scaled offset (pair of numbers) arg (markup)

Translate arg by offset, scaling the offset by the font size.

This function is normally used to move one element inside of a markup relative to the other elements. When using it on the whole markup, bear in mind that spacing mechanisms that place the markup itself on the page could cancel this shift. Consider using grob properties such as padding, X-offset, Y-offset or extra-offset, or spacing variables such as markup-system-spacing.

See also \translate.

\markup {
  \fontsize #5 {
    * \translate #'(2 . 3) translate
    \hspace #2
    * \translate-scaled #'(2 . 3) translate-scaled
  }
}

[image of music]

Used properties:

  • font-size (0)
\vcenter arg (markup)

Align arg to its Y center.

\markup {
  one
  \vcenter two
  three
}

[image of music]

\vspace amount (number)

Create an invisible object taking up vertical space of amount multiplied by 3.

\markup {
    \center-column {
    one
    \vspace #2
    two
    \vspace #5
    three
  }
}

[image of music]

See also \abs-vspace.

\wordwrap args (markup list)

Print args as left-aligned lines.

This function provides simple word-wrap. Use \override #'(line-width . X) to set the line width; X is the number of staff spaces.

\markup {
  \wordwrap {
    Lorem ipsum dolor sit amet, consectetur adipisicing elit,
    sed do eiusmod tempor incididunt ut labore et dolore
    magna aliqua.  Ut enim ad minim veniam, quis nostrud
    exercitation ullamco laboris nisi ut aliquip ex ea
    commodo consequat.
  }
}

[image of music]

The baseline of the output of \wordwrap is the baseline of its first line.

Used properties:

  • text-direction (1)
  • word-space
  • line-width (#f)
  • baseline-skip
\wordwrap-field symbol (symbol)

Word-wrap the data that has been assigned to symbol.

\header {
  title = "My title"
  myText = "Lorem ipsum dolor sit amet, consectetur
    adipisicing elit, sed do eiusmod tempor incididunt ut
    labore et dolore magna aliqua.  Ut enim ad minim
    veniam, quis nostrud exercitation ullamco laboris nisi
    ut aliquip ex ea commodo consequat."
}

\paper {
  bookTitleMarkup = \markup {
    \column {
      \fill-line { \fromproperty #'header:title }
      \null
      \wordwrap-field #'header:myText
    }
  }
}

\markup {
  \null
}

[image of music]

\wordwrap-string arg (string)

Print string arg as left-aligned lines.

Paragraphs are indicated by double newlines. Use \override #'(line-width . X) to set the line width; X is the number of staff spaces.

\markup {
  \override #'(line-width . 40)
  \wordwrap-string "Lorem ipsum dolor sit amet,
      consectetur adipisicing elit, sed do eiusmod tempor
      incididunt ut labore et dolore magna aliqua.


      Ut enim ad minim veniam, quis nostrud exercitation
      ullamco laboris nisi ut aliquip ex ea commodo
      consequat.


      Excepteur sint occaecat cupidatat non proident,
      sunt in culpa qui officia deserunt mollit anim id
      est laborum"
}

[image of music]

The baseline of the output of \wordwrap-string is the baseline of its first line.

Used properties:

  • text-direction (1)
  • word-space
  • line-width
  • baseline-skip

LilyPond Benutzerhandbuch v2.25.22 (development-branch).