Using recent band-structure results obtained in the local-density scheme, the microscopic longitudinal dielectric function for both the diagonal and the nondiagonal elements is evaluated in the random-phase approximation in the energy range up to 2.5 Ryd. In addition, the influence of exchange and correlation is investigated in a self-consistent way within the time-dependent density-functional approach. The authors have found that the latter may modify the frequency dependence of the real elements of the dielectric matrix by up to 15%, whereas some imaginary elements are changed by up to 40%. In the long-wave limit, the local-field corrections of the macroscopic dielectric function seem to be negligible for most frequencies. For the diagonal elements of the inverse dielectric matrix with non-zero reciprocal lattice vectors, local-field corrections increase the real parts by up to 10% at low frequencies, whereas at higher frequencies their influence is quite small. The imaginary parts are decreased over the whole frequency range by up to 30%. For all spectra, local-field corrections smooth the structures and the inclusion of exchange and correlation decreases the values of the elements of dielectric matrix. In addition, for realistic wavefunctions, the f sum rule turned out to be badly fulfilled. Plausible arguments for this failure are presented.