# Horizontal position of grace notes in LilyPond

I am trying to recreate this sort of grace note alignment in lilypond. As it stands, what I have is this:

This is the code I have:

\grace {bes16~ c'~ f'~} <bes c' f' bes'>4\lv

\grace {cis,16~ gis,~ fis~} <cis, gis, fis>4\lv

I have tried to apply \override NoteColumn #'force-hshift to the notes in the grace bracket, and to the grace bracket itself, but this doesn't move it. I also know that I could put all of the notes inside one grace bracket but this wouldn't get me the ties between the different voices in the different staves. Any ideas?

You just need to skip a 3/16 in the upper staff, i. e. change

\grace {bes16~ c'~ f'~} <bes c' f' bes'>4\lv


to

\grace {s8. bes16~ c'~ f'~} <bes c' f' bes'>4\lv


and similarly skip 3/16 in the lower staff like this

\grace {cis,16~ gis,~ fis~ s8.} <cis, gis, fis>4\lv


The reason is that the grace notes take "grace note time", which is effectively zero, but it is used to synchronize grace notes in different voices. (Lilypond sometimes mentions this in some warnings etc., e. g. it can say that an error happened at 3/4+1/8G in bar XY.) By doing this, both grace note constructs take 6/16 of "grace time", and the spacer rests shift the notes accordingly.

Here's a lilybin if you want to see it in action.

If you wanted to recreate that slur over all 6 of the grace notes as well, then it's more interesting and I'm not sure what to do. I would probably "hack it" by making a phrasing slur over the three grace notes in the lower staff and then hacking it with \shape to put the other end into the top staff.

(By the way, what's that piece? It looks like it could be some Villa-Lobos...)

• I would use \grace { s16 s s bes~ c'~ f'~ } but of course a coding style. Reasoning is why change when you don't have to, declaring one thing instead of two, easier code re-read on just one unit. Space between curly braces is Lilypond standard practice (only found out yesterday!)
– user70304
Aug 4, 2020 at 3:56
• @OwainEvans, if I was writing it from the scratch, I would write that too. I just wanted to quickly stick the needed amount of skip into whatever OP provided :—). Aug 4, 2020 at 9:17
• @Ramillis, Hey, fine. I think it was a self reminder to myself (also for other people who read this post): I've Been writing it wrong for many years!
– user70304
Aug 4, 2020 at 10:14
• @Ramillis Thank you very much, I've been using this engraving project to teach myself lilypond, and I like to think I've become rather adept at problem solving with it but sometimes very basic things just slip my mind, I should have thought to do that. As for the piece, it is Sorabji's first piano quintet, though I see where you are getting Villa-Lobos. Aug 5, 2020 at 11:25
• @OwainEvans I know this is somewhat unrelated but if you know where I could find some sort of lilypond style guide or guide to standard practice, I'd be very interested, as I've just been teaching myself and flying by the seat of my pants, I imagine my code is probably very messy. As I've learnt by using LaTeX, what I think is an intuitive way to lay out my work is often not the accepted way. Aug 5, 2020 at 11:26

I'd probably do below. The slur crossing staves is a bit of a pain, as is getting the correct curvature for the slur

\version "2.20.0"

global = {
\key c \major
\time 7/4
\tempo "Tres Lent"
}

right = \relative c' {
\global
\set tieWaitForNote = ##t
\change Staff = "left"
\shape #'((0 . -2) (1 . 2) (-1 . 1) (0 . 1.5)) Slur
\hideNotes \grace { c16^( s s \unHideNotes
\change Staff = "right" bes~[ c_~ f_~] }
<bes, c f bes>4~) q2 c4 c c c |
}

left = \relative c, {
\global
\set tieWaitForNote = ##t
\grace { cis16~[ gis'~ fis'~] s s s }
<cis, gis' fis'>4~ q2 c4 c c c |
}

\score {
\new PianoStaff \with {
} <<
\new Staff = "right" \right
\new Staff = "left" { \clef bass \left }
>>
}


Outputs: