Scanning transmission electron microscopy (STEM) and scanning electron microscopy (SEM) are prominent techniques for the structural characterization of materials. STEM in particular provides high spatial resolution down to the sub-ångström range. The spatial resolution in STEM and SEM is ultimately limited by the electron-beam diameter provided by the microscope's electron optical system. However, the resolution is frequently degraded by the interaction between electron and matter leading to beam broadening, which depends on the thickness of the analyzed sample. Numerous models are available to calculate beam broadening. However, most of them neglect the energy loss of the electrons and large-angle scattering. These restrictions severely limit the applicability of the approaches for large sample thicknesses in STEM and SEM. In this work, we address beam broadening in a more general way. We numerically solve the electron transport equation without any simplifications, and take into account energy loss along the electron path. For this purpose, we developed the software package CeTE (Computation of electron Transport Equation). We determine beam broadening, energy deposition, and the interaction volume of the scattered electrons in homogeneous matter. ... mehrThe calculated spatial and angular distributions of electrons are not limited to forward scattering and small sample thicknesses. We focus on low electron energies of 30 keV and below, where beam broadening is particularly pronounced. These electron energies are typical for SEM and STEM in scanning electron microscopes.