Theory of resonant x-ray emission spectra in compounds with localized f electrons