Lilypond: How can I put the chord names above the right notes?

it's my first time creating a lead sheet with a melody, lyrics and chords. I just can't figure out how to place the chord symbols where I want them, they just appear "anywhere". I looked on the Internet and browsed the documentation on the Lilypond homepage, but sadly couldn't find an answer.

This is the first part of my score:

And this is my code:

harmonies = \chordmode {\set minorChordModifier = \markup { "-" }
\time 6/8
des6 es4:min bes6:min as/f bes:min f:min ges des ges des f:min ges bes:min f:min ges es:min des/es | ges:6 des
}


So the D flat Major chord and the second, the e flat minor, are in the right position. But the B flat minor chord should be after the third barline and the A flat major after the fourth...

I'd like to offer a suggestion, related to your question. Hit "enter" in your music where a measure should end; this will help you visually keep a clear head about where your music is. You can also look into Lilypond's bar checks:

1.2.5 Bar checks

You seem to have written the melody well enough; the chords are just as easy.

For instance, it looks like your melody is this:

melody = \relative c' {
\key des \major
\time 6/8
\partial 4
des8 ees
f4 bes8 aes4 f8
ges4 f8 ees4 ees8
f4 des8 bes bes des
% ...continuing...
}


And chords follow most of the same rules as entering melody:

lead = \chordmode {
\set minorChordModifier = \markup { "-" }
\partial 4
des4
s2.
ees4.:m bes:m
aes2./f
% ...continuing...
}


And then together:

\score {
<<
\new Staff \melody
>>
}


You obviously wrote the melody down with no trouble, so your problem here with the chords is likely that you just missed counting a rhythm value somewhere. By setting up your music in the way I outlined above, you can quickly see what the start of each measure is supposed to be, and you can easily count each measure to see if it adds up.

Just as another short example, if I wrote the following:

\relative c' { \time 3/4 d4 e2 g2 a4 b d8 a g4~ g2 b c2 fis16 g bes a ees4 aes ces ges2 cis4 bis2. ais }


And there is one rhythm error, can you quickly point it out?

Now try it again with the music separated according to measures:

 \relative c' {
\time 3/4
d4 e2
g2 a4
b d8 a g4~
g2 b
c2 fis16 g bes a
ees4 aes ces
ges2 cis4
bis2.
ais
}


You can more easily check where a measure has gone wrong: the fourth measure, which is the fourth line of my melody: there's a g2 followed by a b. Since there is no number after the b, it takes whatever the previous rhythmic value was... namely a 2, a half note, and you know you can't fit two of those in a single measure of 3/4 time!

I believe this answers your question of how you can put the chords above the correct notes... but I also hope it helps you to avoid some problems in the future, so you can focus more of your energy on getting that beautiful music written and less time figuring out where the rhythm went wrong. :) I've been there. Oh, I've been there.

Happy Lilyponding!

Without seeing your full code, there are two possible issues:

1. Make sure you include a \partial 4 in your harmonies block to match the anacrusis in the melody.
2. Also make sure you're using correct duration markings in the harmonies block; des6 is unclear, since 6 isn't a real duration. If the Ef-minor chord should last that entire measure, you should input es2.:min to show that it will last a duration of a dotted-half note (that is, 6 eighth notes).

Your input appears to be chaotic: I cannot blame LilyPond for not knowing what to do with it. In chordmode, a note is written

<root name> <duration> : <named chord modifiers> <numbered chord modifiers>


Now you start out with des6 which is already nonsensical since 6 is not a valid note duration (by the way: LilyPond's error messages are pretty important for figuring out what happens: you should not just ignore them). Durations are 1 2 4 8 (for whole, half, quarter, eighth notes), possibly followed by dots, possibly followed by a multiplier like *5 or *5/8: particularly with chords and lyrics it is pretty common to have to work with multipliers in order to get the total length right.

So the first note maybe was intended to be des8*8:6 in order to indicate a D♭6 chord with a duration of 8 eighth notes? Just guessing.