When writing music in sheet music form, I know that when writing harmonic intervals of a second, one of the two notes is on the opposite side of the notehead. My trouble is determining which note to put on the opposite side of the stem. What are the conventions as to which noteheads go on which side of the stem? Do lines and spaces make the difference? Is it vertical position on the staff? And how does this apply to the same situation when the two notes are in different voices?
I've always understood that the lower pitch of the harmonic second occurs on the left side:
This is also true when additional pitches are added in. On beat four, the E is now on the right because the first second encountered is D–E (and no longer E–F).
When you're writing separate voices, however, you write the higher pitch first, with the lower voice offset a bit to the right:
Some comments are wondering if these are just the LilyPond standards, since that's why I used to create these examples. They are, but keep in mind too that LilyPond is exceedingly well-researched, creating their notational algorithms by following notational tradition as well as notational manuals. For anyone interested, consult page 29 of LilyPond's Essay on Automated Music Engraving to see nine pages of bibliography they consulted in creating the software.