We present a new formalism for the diffraction of an electromagnetic plane wave by a multicoated grating. Its basic feature lies in the use of a coordinate system that maps all the interfaces onto parallel planes. Using Maxwell's equations in this new system leads to a linear system of differential equations with constant coefficients whose solution is obtained through the calculation of the eigenvalues and eigenvectors of a matrix in each medium. Through classical criteria, our numerical results have been found generally to be accurate to within 1%. The serious numerical difficulties encountered by the previous differential formalism for highly conducting metallic gratings completely disappear, whatever the optical region. Furthermore, our computer code provides accurate results for metallic gratings covered by many modulated dielectric coatings or for highly modulated gratings. We give two kinds of applications. The first concerns the use of dielectric coatings on a modulated metallic substrate to minimize the absorption of energy. Conversely, the second describes the use of highly modulated metallic gratings to increase this absorption.