Monte Carlo simulation is a suitable tool for the numerical generation of x-ray spectra by electron beams and, more specifically, for the quantification in electron probe microanalysis (EPMA). in this communication we describe the application of the general-purpose code PENELOPE to EPMA. This code simulates electron-photon showers in complex material structures consisting of homogeneous regions of arbitrary composition limited by quadric surfaces. It is devised to cover a wide energy range (from ∼500 eV to about 1 GeV). The interaction models implemented in PENELOPE are based on the most reliable information available. They combine results from first principles calculations (this is the case, e.g., for electron elastic scattering, photon Compton scattering), semiempirical models (in electron inelastic scattering) and information from evaluated data bases. to facilitate the random sampling, the cross sections of various interaction mechanisms are described through analytical expressions, which are adjusted to yield accurate values of relevant transport properties (mass attenuation coefficients, transport mean free paths, stopping powers, . . . ).