Stacked rest-frame ultraviolet spectra of Ly alpha-emitting and continuum-selected galaxies at 2 < z < 3.5