One of the most common sources of distortion in in vivo spectroscopy is the inhomogeneity of the main magnetic field. This effect is particularly problematic when performing spectroscopic imaging, as the shim cannot be simultaneously optimized for all voxels. In this paper we present a technique to measure inhomogeneity rapidly, then show how to use the measurement to improve the analysis of the spectrum. This technique can be applied in conjunction with any spectroscopic localization method and any spectral quantitation algorithm. We present results from spectroscopic imaging of phantoms, then show application to a single-voxel water-suppressed proton brain study. We find that the quantitation of the in vivo spectrum is made immune to inhomogeneous line broadening.