The staff-padding property

staff-padding can be used to align objects such as dynamics along a baseline at a fixed distance from the staff, when no other notation forces them further from the staff. It is not a property of DynamicText but of DynamicLineSpanner. This is because the baseline should apply equally to all dynamics, including those created as extended spanners. So this is the way to align the dynamic marks in the example taken from the previous section:

\override DynamicLineSpanner.staff-padding = 3
\relative { a'4\f b\mf a\p b\mp }

[image of music]

LilyPond 学习手册 v2.25.22 (development-branch).