| [ << Vertical spacing ] | [Top][Contents][Index] | [ Horizontal spacing >> ] |
| [ < Spacing of non-staff lines ] | [ Up: Vertical spacing ] | [ Vertical collision avoidance > ] |
29.2 Explicit staff and system positioning
It is possible to approach vertical spacing in a different way (in
comparison to what was demonstrated in the previous sections) by
using the property line-break-system-details of the
NonMusicalPaperColumn grob. While the flexible vertical
spacing mechanisms specify vertical padding,
line-break-system-details can specify exact vertical
positions on the page.
This property contains five different subproperties:
X-offset, Y-offset, extra-offset,
alignment-distances, and bottom-padding.
To understand how each of these different subproperties work, we begin by looking at an example that includes no overrides at all. We isolate both line breaking and page breaking information in a dedicated voice, dividing the music into five measures per line. This technique of creating an otherwise empty voice for breaks helps in keeping layout separate from music entry as our example becomes more complicated. Also see Breaks.
\book { \score { << \new Staff << \new Voice { s1*5 \break s1*5 \break s1*5 \break } \new Voice { \repeat unfold 15 { c'4 c' c' c' } } >> \new Staff { \repeat unfold 15 { d'4 d' d' d' } } >> } }![]()
We now set the vertical and horizontal start points of each system
explicitly by using the Y-offset and X-offset
subproperties of line-break-system-details.
\book { \score { << \new Staff << \new Voice { \once \override Score.NonMusicalPaperColumn .line-break-system-details.Y-offset = 0 s1*5 \break \once \override Score.NonMusicalPaperColumn .line-break-system-details.Y-offset = 30 \once \override Score.NonMusicalPaperColumn .line-break-system-details.X-offset = 10 s1*5 \break \once \override Score.NonMusicalPaperColumn .line-break-system-details.Y-offset = 50 s1*5 \break } \new Voice { \repeat unfold 15 { c'4 c' c' c' } } >> \new Staff { \repeat unfold 15 { d'4 d' d' d' } } >> } }![]()
In contrast to the absolute positioning available through
Y-offset and X-offset, relative positioning is
possible with the extra-offset subproperty. Placement is
relative to the default layout or to the absolute positioning
created by setting X-offset and Y-offset. The
subproperty extra-offset accepts a pair consisting
of displacements along the X- and Y-axis.
\book { \score { << \new Staff << \new Voice { s1*5 \break \once \override Score.NonMusicalPaperColumn .line-break-system-details.extra-offset = #'(5 . 5) s1*5 \break \once \override Score.NonMusicalPaperColumn .line-break-system-details.extra-offset = #'(0 . 20) s1*5 \break } \new Voice { \repeat unfold 15 { c'4 c' c' c' } } >> \new Staff { \repeat unfold 15 { d'4 d' d' d' } } >> } }![]()
Now that we have set the vertical start point of each system
explicitly, we can also set the vertical distances between staves
within each system manually by modifying the
alignment-distances subproperty. As can be seen, we use an
alist to set two different line-break-system-details
subproperties at the same time.
\book { \score { << \new Staff << \new Voice { \once \override Score.NonMusicalPaperColumn.line-break-system-details = #'((Y-offset . 0) (alignment-distances . (10))) s1*5 \break \once \override Score.NonMusicalPaperColumn.line-break-system-details = #'((Y-offset . 30) (alignment-distances . (15))) s1*5 \break \once \override Score.NonMusicalPaperColumn.line-break-system-details = #'((Y-offset . 65) (alignment-distances . (20))) s1*5 \break } \new Voice { \repeat unfold 15 { c'4 c' c' c' } } >> \new Staff { \repeat unfold 15 { d'4 d' d' d' } } >> } }![]()
The next example shows how to set vertical positions of multiple
staves in a system. Note that alignment-distances directly
applies to staves, not taking care of grouping with
StaffGroup or the like. Value #f indicates that the
default value should be used.
\book { \score { << \new Staff << \new Voice { \once \override Score.NonMusicalPaperColumn.line-break-system-details = #'((Y-offset . 0) (alignment-distances . (15 8))) s1*5 \break \once \override Score.NonMusicalPaperColumn.line-break-system-details = #'((Y-offset . 35) (X-offset . 10) (alignment-distances . (#f 8))) s1*5 \break \once \override Score.NonMusicalPaperColumn.line-break-system-details = #'((Y-offset . 65) (alignment-distances . (8 15))) s1*5 \break } \new Voice { \repeat unfold 15 { c'4 c' c' c' } } >> \new StaffGroup << \new Staff { \repeat unfold 15 { d'4 d' d' d' } } \new Staff { \repeat unfold 15 { e'4 e' e' e' } } >> >> } }![]()
The last subproperty of line-break-system-details,
bottom-padding, has a similar effect as
last-bottom-spacing. Note, however, that it doesn’t hold a
compressible or stretchable spacing dimension but a rigid, fixed
padding value from the bottom of the page to the lowest staff.
Here is the test snippet without a ragged bottom, showing the
default distance.
\book { \score { << \new Staff << \new Voice { s1*5 \break s1*5 \break s1*5 \break } \new Voice { \repeat unfold 15 { c'4 c' c' c' } } >> \new Staff { \repeat unfold 15 { d'4 d' d' d' } } >> } \paper { ragged-last-bottom = ##f } }![]()
Setting bottom-padding yields the following result.
\book { \score { << \new Staff << \new Voice { s1*5 \break s1*5 \break \once \override Score.NonMusicalPaperColumn.line-break-system-details = #'((bottom-padding . 20)) s1*5 \break } \new Voice { \repeat unfold 15 { c'4 c' c' c' } } >> \new Staff { \repeat unfold 15 { d'4 d' d' d' } } >> } \paper { ragged-last-bottom = ##f } }![]()
Some points to consider:
- When using
alignment-distances, lyrics and other non-staff lines do not count as a staff. - The units of the numbers passed to the
X-offset,Y-offset,extra-offset, andalignment-distancessubproperties are interpreted as multiples of the distance between adjacent staff lines. Positive values move staves and lyrics up, negative values move staves and lyrics down. - Because the
NonMusicalPaperColumn.line-break-system-detailssettings given here allow the positioning of staves and systems anywhere on the page, it is possible to violate paper or margin boundaries or even to print staves or systems on top of one another. Use reasonable values for the subproperties to avoid this.
See also
Snippets: Spacing.
| [Top][Contents][Index] |
![[image of music]](../7a/lily-0fb5aeff.png)
![[image of music]](../d6/lily-67bde00c.png)
![[image of music]](../7d/lily-33597acb.png)
![[image of music]](../9f/lily-716f8afe.png)
![[image of music]](../e3/lily-072cc1a1.png)
![[image of music]](../80/lily-e79ca181.png)
![[image of music]](../57/lily-a2b79e9a.png)