Hm. This is *supposed* to be the situation where \override
DynamicText.X-align-on-main-noteheads = ##t (which is the default actually)
saves the day. And if the \sf is attached directly to the chord, it does.
But when it's in a different staff context, it doesn't do anything, since
DynamicText lacks a NoteColumn as its parent. It's just positioned relative
to the total extent of the musical paper column, which doesn't have any
convenient way to match the positioning with respect to the noteheads.

I'd say this is a bug. The choice to use a Dynamics context shouldn't
affect horizontal alignment of dynamics. I didn't see any existing issue
tracking this, so it is now
https://gitlab.com/lilypond/lilypond/-/issues/6773.

Saul

On Sat, Jan 4, 2025 at 10:18 AM Richard Shann <rich...@rshann.plus.com>
wrote:

>
>
> In a large orchestral piece it was noticed that a dynamic under a note
> was slightly displaced to the right. It turned out that this was
> because many staffs below there was a chord with notes on both sides of
> the stem (because only a semitone apart).
> The dynamic was placed in a dynamics staff as there were hairpins that
> it had to align with.
> Here is an MWE which illustrates the problem.
>
>
> 8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><
> \version "2.24"
> \score {
>           <<
>             \new Staff
>              {g''4 r8
>               d''  % \sf
>               d''2   }
>
>             \new Dynamics \with {  \override
> VerticalAxisGroup.staff-affinity = #UP
>              }
>               { r4.
>                 r8\sf
>                 r2 }
> %many more staffs follow in the original then:
>             \new Staff   {    g'4 e'8 <c '
>                                         d' %with this note commented out
> all is well
>                                          > r2  }
>           >>
>        }
> 8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><
>
> Any suggestions would be most welcome!
> Richard Shann
>
>
>

Reply via email to