I am trying to make something like this in LilyPond, where the note in the upper stave is aligned with the grace notes in the lower staff:
Any solution should also work after a time signature change, hence the example.
It's to be played similarly as when notated with a guide line (like this). A guide line wouldn't be very fitting in this case, though, so I'm trying to indicate it spatially. Using a new spacing section like here does not solve the problem.
The best I've managed so far is to just move the upper note with X-offsets. An unpleasant but manageable disadvantage of this is that you have to manually check how far you have to move it. If you for example uncomment the new spacing section in the code, the notes in the third bar are not aligned anymore. Also the overall spacing in the third bar is pretty bad, but this can be fixed by simply moving the last quarter note the same space to the right as the other was moved to the left.
Is there any better, more consistent and elegant way to do this? (Could one for example have LilyPond treat the note and grace note I want vertically aligned as a sort of unit, so that they're always aligned like normal notes usually are? Or are there other ideas?)
My code:
\version "2.22.2"
NotesLeft = {
\override NoteHead.X-offset = -3.5
\override Stem.X-offset = -3.5
\override Beam.X-offset = -3.5
}
NotesRestore = {
\revert NoteHead.X-offset
\revert Stem.X-offset
\revert Beam.X-offset
}
\score {
\new PianoStaff <<
\new Staff \relative c'' {
\numericTimeSignature \time 4/4
\grace{s16} a1 | \time 5/4
\grace{s8} \NotesLeft c1~ \NotesRestore c4 |
c2 \NotesLeft c2 \NotesRestore g4 |
}
\new Staff \relative c {\clef bass \numericTimeSignature
\grace{e16} f1 | %\time 5/4
\grace{c16 g'} e'2~ e2. |
%\newSpacingSection
%\override Score.SpacingSpanner.strict-grace-spacing = ##t
e2 \grace{c,8 g'} e'2. |
}
>>
}