A quantitatively correct theory of the simulation of electron micrographs is proposed which considers the partially coherent process of image formation within the electron microscope. The new approach is based on the propagation of the mutual coherence function of the partially coherent electron wave field. Our method leads to the formulation of a generalized multislice algorithm. Applications to imaging with zero-loss electrons and inelastically scattered electrons are presented. In addition the effect of thermal diffuse scattering is investigated in detail.