A novel method based on average Hamiltonian theory to design selective pulses is reported. With this tool, it is first shown how to shape the radiofrequency and gradient pulses to generate a desired rotation matrix, which is independent of the position through the slice of interest. After theoretical examination of the concept, it is applied to the strongly modulating pulses' recipe developed by the same authors and initially designed to be nonselective, to mitigate the amplitude of (excitation) radiofrequency field and amplitude of static (polarizing) field inhomogeneity problems at high field. Two in vivo human brain imaging experiments at 7 T are reported to prove the validity of the technique. Magn Reson Med, 2011. © 2010 Wiley-Liss, Inc.