[ << Spacing issues ] | [Top][Contents][Index][ ? ] | [ Changing defaults >> ] | ||
[ < Vertical spacing ] | [ Up : Vertical spacing ] | [ > ] |
4.4.1 Vertical spacing inside a system
The height of each system is determined in two steps. First, all of the staves are spaced according to the amount of space available. Then, the non-staff lines (eg. lyrics or chords) are distributed between the staves.
[ << Spacing issues ] | [Top][Contents][Index][ ? ] | [ Changing defaults >> ] | ||
[ < Vertical spacing inside a system ] | [ Up : Vertical spacing inside a system ] | [ > ] |
Spacing between staves
Spacing between staves is controlled by the next-staff-spacing property of the VerticalAxisGroup grob. This property is an alist with four elements: space, minimum-distance, padding and stretchability:
- space is the size of the stretchable space between the center line of one staff to the center line of the next staff.
- minimum-distance provides a lower bound on the final distance between the center line of one staff to the center line of the next staff. That is, if a page has many systems and needs to be compressed, the distance from this staff to the next will never be compressed to less than minimum-distance.
- padding is the amount of whitespace that must be present between the bottom of one staff and the top of the next. It differs from minimum-distance in that the effect of padding depends on the height of objects in the staff. For example, padding is more likely to come into effect for staves with notes that are far below the staff.
-
stretchability controls the stretchable space’s propensity to
stretch when the system is stretched. Large values will cause a
system to stretch more, while a value of zero will prevent the
space from stretching at all. If unset, stretchability
defaults to
space - minimum-distance
.
#(set-global-staff-size 16) \new StaffGroup << % Since space is small and there is no minimum-distance, the distance % between this staff and the next will be determined by padding. \new Staff \with { \override VerticalAxisGroup #'next-staff-spacing = #'((space . 1) (padding . 1)) } { \clef bass c, } % Since space is small and nothing sticks out very far, the distance % between this staff and the next will be determined by minimum-distance. \new Staff \with { \override VerticalAxisGroup #'next-staff-spacing = #'((space . 1) (minimum-distance . 12)) } { \clef bass c, } % By setting padding to a negative value, staves can be made to collide. \new Staff \with { \override VerticalAxisGroup #'next-staff-spacing = #'((space . 4) (padding . -10)) } { \clef bass c, } \new Staff { \clef bass c, } >>
In orchestral and other large scores, it is common to place staves in groups. The space between groups is typically larger than the space between staves of the same group. This spacing can be tweaked with the StaffGrouper grob: the default value of next-staff-spacing for VerticalAxisGroup is a callback function which operates by searching for a StaffGrouper grob containing the staff. If it finds a StaffGrouper grob and the staff in question is in the middle of a group, it reads the between-staff-spacing property of StaffGrouper and returns it. If the staff in question is the last staff of a group, the callback reads the after-last-staff-spacing property of StaffGrouper and returns it. If the callback did not find a StaffGrouper grob, it reads default-next-staff-spacing from its VerticalAxisGroup and returns that.
#(set-global-staff-size 16) << \new PianoStaff \with { \override StaffGrouper #'between-staff-spacing #'space = #1 \override StaffGrouper #'between-staff-spacing #'padding = #0 \override StaffGrouper #'after-last-staff-spacing #'space = #20 } << \new Staff c'1 \new Staff c'1 >> \new StaffGroup \with { \override StaffGrouper #'between-staff-spacing #'space = #1 \override StaffGrouper #'between-staff-spacing #'padding = #0 } << \new Staff c'1 \new Staff c'1 >> >>
[ << Spacing issues ] | [Top][Contents][Index][ ? ] | [ Changing defaults >> ] | ||
[ < ] | [ Up : Vertical spacing inside a system ] | [ Vertical spacing between systems > ] |
Spacing of non-staff lines
After the positions of the staves are determined, the non-staff lines are distributed between the staves. Each of these lines has a staff-affinity property which controls its vertical alignment. For example,
\new Lyrics \with { \override VerticalAxisGroup #'staff-affinity = #DOWN }
creates a lyrics context that will be placed close to the
staff below it. Setting staff-affinity to something which is not
a number (#f
, for example) will cause that line to be treated
like a staff. Conversely, setting staff-affinity for a staff will
cause it to be treated like a non-staff.
Non-staff lines admit three properties to control their spacing. Each of the these properties is an alist of the same format as next-staff-spacing, above.
-
If the nearest line in the staff-affinity direction is a staff
then inter-staff-spacing gives the spacing between the non-staff
and the staff. If staff-affinity is
CENTER
, then inter-staff-spacing is used for both directions. - If the nearest line in the staff-affinity direction is a non-staff then inter-loose-line-spacing gives the spacing between the two non-staff lines.
- If the nearest line in the opposite direction to staff-affinity is a staff then non-affinity-spacing gives the spacing between the non-staff and the staff. This can be used, for example, to require a minimum amount of padding between a Lyrics line and the staff to which it does not belong.
#(set-global-staff-size 16) \layout { \context { \Lyrics % By default, Lyrics are placed close together. Here, we allow them to % be stretched more widely. \override VerticalAxisGroup #'inter-loose-line-spacing #'stretchability = #1000 } } \new StaffGroup << \new Staff \with { \override VerticalAxisGroup #'next-staff-spacing = #'((space . 30)) } { c'1 } \new Lyrics \with { \override VerticalAxisGroup #'staff-affinity = #UP } \lyricmode { up } \new Lyrics \with { \override VerticalAxisGroup #'staff-affinity = #CENTER } \lyricmode { center } \new Lyrics \with { \override VerticalAxisGroup #'staff-affinity = #DOWN } \lyricmode { down } \new Staff { c'1 } >>
See also
Snippets: Spacing.
Internals Reference: VerticalAxisGroup, VerticalAlignment, Axis_group_engraver.
Known issues and warnings
Adjacent non-staff lines should have non-increasing staff-affinity from top-to-bottom. For example, the behavior of
<< \new Staff c \new Lyrics \with { \override VerticalAxisGroup #'staff-affinity = #DOWN } \new Lyrics \with { \override VerticalAxisGroup #'staff-affinity = #UP } \new Staff c >>
is undefined.
A non-staff line at the bottom of a system should have
staff-affinity set to UP
. Similarly, a non-staff
line at the top of a system should have staff-affinity set
to DOWN
.
[ << Spacing issues ] | [Top][Contents][Index][ ? ] | [ Changing defaults >> ] | ||
[ < ] | [ Up : Vertical spacing inside a system ] | [ Vertical spacing between systems > ] |