Jump to content

Breaking horizontal alignment of dynamics and textscripts: Difference between revisions

From LilyPond wiki
Created page with "LilyPond uses <code>DynamicLineSpanner</code> grobs to horizontally align successive dynamic objects like hairpins and dynamic text, even if they are positioned on different sides of a staff. This connection cannot be broken, contrary to the vertical alignment (see snippet Breaking vertical alignment of dynamics and textscripts). There are two solutions to circumvent the problem. * Modify the <code>shorten-pair</code> property of the <code>Hairpin</code> grob to c..."
 
mNo edit summary
 
Line 4: Line 4:


* Modify the <code>shorten-pair</code> property of the <code>Hairpin</code> grob to compensate the offset by which the hairpin was moved.
* Modify the <code>shorten-pair</code> property of the <code>Hairpin</code> grob to compensate the offset by which the hairpin was moved.
* Put the two dynamic objects into two different voices.
* Put the two dynamic objects into different voices.


Both solutions are demonstrated in this snippet.
Both solutions are demonstrated in this snippet.

Latest revision as of 21:48, 17 December 2025

LilyPond uses DynamicLineSpanner grobs to horizontally align successive dynamic objects like hairpins and dynamic text, even if they are positioned on different sides of a staff. This connection cannot be broken, contrary to the vertical alignment (see snippet Breaking vertical alignment of dynamics and textscripts).

There are two solutions to circumvent the problem.

  • Modify the shorten-pair property of the Hairpin grob to compensate the offset by which the hairpin was moved.
  • Put the two dynamic objects into different voices.

Both solutions are demonstrated in this snippet.

\version "2.24.4"

{
  <>^"default"
  f'_\pp ^\> f' f' f'\!
}

{
  <>^\markup { setting \typewriter shorten-pair }
  f'_\pp \tweak shorten-pair #'(-3 . 0) ^\> f' f' f'\!
}

{
  <>^\markup { using another \typewriter Voice context }
  << { f'^\> f' f' f'\! }
     \new Voice { s4_\pp } >>
}

\layout {
  line-width = 8\cm
  ragged-right = ##f

  \context {
    \Voice
    \override TextScript.staff-padding = #3.5
  }
}