Jump to content

Dashed individual staff lines

From LilyPond wiki
Revision as of 18:47, 16 November 2025 by Jean Abou Samra (talk | contribs) (Replace version="2.24.0" with version="2.24" now that the LilyWiki extension supports auto-selecting the latest release in a stable series)

You can customize a staff so that some (or all) of its lines are dashed instead of solid. This snippet defines a music function called "dashedStaffSymbolLines" that replaces specified lines of a StaffSymbol with dashed lines. For example, the following will replace the center line of the staff with a dashed line:

\dashedStaffSymbolLines #'( #f #f #t #f #f )

A list containing booleans (#t and #f) indicates which lines are to be dashed. (#t means dashed, #f means normal and unchanged)

The width of the dashes and the spacing between them can optionally be customized by adding a pair of values as the first argument when calling the function. The first number of the pair is the width, the second is the spacing. (The default is 0.5 for both.) The following will create wider dashes (1.5) with more space between them (1.2):

\dashedStaffSymbolLines #'(1.5 . 1.2) #'(#f #f #t #f #f)

The function also works with staves that have different numbers of lines and/or different line positions.

LilyPond rendering error

No release of LilyPond 2.24 found.