I'm quite new to Lilypond, and have been trying to produce something like in the attached picture:
Here's a minimal example of what I tried, which doesn't work. How do I prevent the note in the upper staff to be shifted so much to the right? Should I use an entirely different approach?
Would be very grateful for any help!
\version "2.20.0" % necessary for upgrading to future LilyPond versions.
upper = \relative c' {
\clef treble
\key c \major
\time 4/4
<<f4 a>> <<f a>> <<f a>> <<e g>> |
}
lower = \relative c' {
\clef bass
\key c \major
\time 4/4
<< f, a {\(c \change Staff = "upper" c \)}>>\change Staff = "lower"
<< f, a {\(c \change Staff = "upper" c\)} >>\change Staff = "lower"
<< f, a {\(c \change Staff = "upper" c\)} >>\change Staff = "lower"
<< c, g'{\(c \change Staff = "upper" c\)} >>\change Staff = "lower"
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\score {
\new PianoStaff
<<
\new Staff = "upper" \upper
\new Staff = "lower" \lower
>>
\layout {}
\midi { }
}