It seems that the tikzpicture environment always leaves vertical mode, even when the overlay option is given (and thus the picture doesn't actually take any space). This can cause unexpected behaviour.