Jump to content

Cross-staff stems: Difference between revisions

From LilyPond wiki
m Replace version="2.24.0" with version="2.24" now that the LilyWiki extension supports auto-selecting the latest release in a stable series
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
This snippet shows how to use <code>Span_stem_engraver</code> and <code>\crossStaff</code> to connect stems across staves automatically.
This snippet shows how to use <code>Span_stem_engraver</code> and <code>\crossStaff</code> to connect stems across staves automatically.


The stem length need not be specified, as the variable distance between noteheads and staves is calculated automatically. However, it is important that <code>\crossStaff</code> is applied to the correct voice or staff (i.e., on the opposite side of where a beam is or would be positioned) to get the desired effect.
The stem length need not be specified, as the variable distance between note heads and staves is calculated automatically. However, it is important that <code>\crossStaff</code> is applied to the correct voice or staff (i.e., on the opposite side of where a beam is or would be positioned) to get the desired effect.


<lilypond version="2.24">
<lilypond version="2.24">
Line 30: Line 30:
</lilypond>
</lilypond>


[[Category:Included in the official documentation]]
[[Category:Contexts and engravers]]
[[Category:Staff notation]]
[[Category:Staff notation]]
[[Category:Tweaks and overrides]]
[[Category:Tweaks and overrides]]
[[Category:Contexts and engravers]]
[[Category:Included in the official documentation]]
[[Category:Snippet]]

Latest revision as of 12:00, 5 December 2025

This snippet shows how to use Span_stem_engraver and \crossStaff to connect stems across staves automatically.

The stem length need not be specified, as the variable distance between note heads and staves is calculated automatically. However, it is important that \crossStaff is applied to the correct voice or staff (i.e., on the opposite side of where a beam is or would be positioned) to get the desired effect.

\version "2.24"

\layout {
  \context {
    \PianoStaff
    \consists "Span_stem_engraver"
  }
}

\new PianoStaff <<
  \new Staff {
    <b d'>4 r d'16\> e'8. g8 r\! |
    e'8 f' g'4
      \voiceTwo \autoBeamOff
      % Down to lower staff
      \crossStaff { e'8 e'8 } e'4 |
  }

  \new Staff {
    \clef bass
    \voiceOne \autoBeamOff
    % Up to upper staff
    \crossStaff { <e g>4 e, g16 a8. c8 } d |
    \autoBeamOn g8 f g4 \voiceTwo g8 g g4 |
    }
>>