Consistent theory of electron scattering with atoms in electron microscopes