GNU LilyPond Notation Reference: 4.4.1 Vertical spacing inside a system

### 4.4.1 Vertical spacing inside a system

The height of each system is determined automatically. To prevent staves from bumping into each other, some minimum distances are set. By changing these, you can put staves closer together. This reduces the amount of space each system requires, and may result in having more systems per page.

Normally staves are stacked vertically. To make staves maintain a distance, their vertical size is padded. This is done with the property `minimum-Y-extent`. When applied to a VerticalAxisGroup, it controls the size of a horizontal line, such as a staff or a line of lyrics. `minimum-Y-extent` takes a pair of numbers, so if you want to make it smaller than its default `#'(-4 . 4)` then you could set

>     \override Staff.VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3)

This sets the vertical size of the current staff to 3 staff spaces on either side of the center staff line. The value `(-3 . 3)` is interpreted as an interval, where the center line is the 0, so the first number is generally negative. The numbers need not match; for example, the staff can be made larger at the bottom by setting it to `(-6 . 4)`.

After page breaks are determined, the vertical spacing within each system is reevaluated in order to fill the page more evenly; if a page has space left over, systems are stretched in order to fill that space. The amount of stretching can be configured though the `max-stretch` property of the VerticalAlignment grob. By default, `max-stretch` is set to zero, disabling stretching. To enable stretching, a sane value for `max-stretch` is `ly:align-interface::calc-max-stretch`.

In some situations, you may want to stretch most of a system while leaving some parts fixed. For example, if a piano part occurs in the middle of an orchestral score, you may want to leave the piano staves close to each other while stretching the rest of the score. The `keep-fixed-while-stretching` property of VerticalAxisGroup can be used to achieve this. When set to `##t`, this property keeps its staff (or line of lyrics) from moving relative to the one directly above it. In the example above, you would override `keep-fixed-while-stretching` to `##t` in the second piano staff:

    #(set-default-paper-size "a6")
    #(set-global-staff-size 14.0)

    \book {
    \paper {
      ragged-last-bottom = ##f
    }

    \new Score \with
    {
      \override VerticalAlignment #'max-stretch = #ly:align-interface::calc-max-stretch
    }
    {
    \new GrandStaff
    <<
      \new StaffGroup
      <<
        \new Staff {c' d' e' f'}
        \new Staff {c' d' e' f'}
        \new Staff {c' d' e' f'}
      >>

      \new PianoStaff
      <<
        \new Staff {c' d' e' f'}
        \new Staff \with {
          \override VerticalAxisGroup #'keep-fixed-while-stretching = ##t
        }
        {c' d' e' f'}
      >>

      \new StaffGroup
      <<
        \new Staff {c' d' e' f'}
        \new Staff {c' d' e' f'}
      >>
    >>
    }
    }

Vertical alignment of staves is handled by the `VerticalAlignment` object. The context parameters specifying the vertical extent are described in connection with the `Axis_group_engraver`.

#### See also

Snippets: Spacing.

Internals Reference: VerticalAlignment, Axis_group_engraver.

Other languages: español.

#### Notation Reference