Theory of the resonance Raman effect in crystals