5.4.6 Line spanners

Some performance indications, e.g., rallentando and accelerando and trills are written as text and are extended over many measures with lines, sometimes dotted or wavy.

The locations of the two end points of the spanner are computed on the fly, but it is possible to override their Y-coordinates. The properties that need to be specified are nested two levels down within the property hierarchy, but the syntax of the \override command is quite simple:

e''2 \glissando b'
\once \override Glissando.bound-details.left.Y = #3
\once \override Glissando.bound-details.right.Y = #-2
e''2 \glissando b'

[image of music]

The units for the Y property are staff spaces, with the center line of the staff being the zero point. For the glissando, this is the value for Y at the X-coordinate corresponding to the center point of each note head, if the line is imagined to be extended to there.

If Y is not set, the value is computed from the vertical position of the corresponding attachment point of the spanner.

In case of a line break, the values for the end points are specified by the left-broken and right-broken sublists of bound-details. For example:

\override Glissando.breakable = ##t
\override Glissando.bound-details.right-broken.Y = #-3
c''1 \glissando \break

[image of music]

A number of further properties of the left and right sublists of the bound-details property may be modified in the same way as Y:


This sets the Y-coordinate of the end point, measured in staff spaces from the staff center line. By default, it is the center of the bound object, so a glissando points to the vertical center of the note head.

For horizontal spanners, such as text spanners and trill spanners, it is hardcoded to 0.


This determines where the line starts and ends in the X-direction, relative to the bound object. So, a value of -1 (or LEFT) makes the line start/end at the left side of the note head it is attached to.


This is the absolute X-coordinate of the end point. It is usually computed on the fly, and overriding it has little useful effect.


Line spanners may have symbols at the beginning or end, which is contained in this subproperty. This is for internal use; it is recommended that text be used instead.


This is a markup that is evaluated to yield the stencil. It is used to put cresc., tr, and other text on horizontal spanners.

\override TextSpanner.bound-details.left.text
   = \markup { \small \bold Slower }
\relative { c''2\startTextSpan b c a\stopTextSpan }

[image of music]


Without setting one of these, the stencil is simply put at the end point, centered on the line, as defined by the X and Y subproperties. Setting either stencil-align-dir-y or stencil-offset will move the symbol at the edge vertically relative to the end point of the line:

\override TextSpanner.bound-details
          .left.stencil-align-dir-y = #-2
\override TextSpanner.bound-details
          .right.stencil-align-dir-y = #UP

\override TextSpanner.bound-details.left.text = "ggg"
\override TextSpanner.bound-details.right.text = "hhh"

\relative { c'4^\startTextSpan c c c \stopTextSpan }

[image of music]

Note that negative values move the text up, contrary to the effect that might be expected, as a value of -1 or DOWN means align the bottom edge of the text with the spanner line. A value of 1 or UP aligns the top edge of the text with the spanner line.


Setting this subproperty to #t produces an arrowhead at the end points of the line.


This subproperty controls the space between the specified end point of the line and the actual end. Without padding, a glissando would start and end in the center of each note head.

The music function \endSpanners terminates the spanner which starts on the immediately following note prematurely. It is terminated after exactly one note, or at the following bar line if to-barline is true and a bar line occurs before the next note.

\relative c'' {
  c2 \startTextSpan c2 c2
  c2 \< c2 c2

[image of music]

When using \endSpanners it is not necessary to close \startTextSpan with \stopTextSpan, nor is it necessary to close hairpins with \!.

See also

Internals Reference: TextSpanner, Glissando, VoiceFollower, TrillSpanner, line-spanner-interface.

LilyPond — Notation Reference v2.23.10 (development-branch).