Electron energy loss spectroscopy (EELS) is a widely applied microanalytical technique. Spectrometers for EELS, some of which can record spectra in parallel, are available on many modern analytical electron microscopes. A theory for variations in the EELS cross section with diffraction conditions and thickness in a crystalline environment is discussed, focusing on inner-shell ionization. The localization of the interaction as well as attenuation of dynamical effects by thermal diffuse scattering are explicitly taken into account. Agreement between theory and a previous EELS experiment reported in the literature under dynamical electron diffraction conditions is satisfactory. Application of the theory to atom location by channeling-enhanced microanalysis (ALCHEMI) is discussed.