We present an accurate and self-consistent technique for computing the electromagnetic held in scattering structures formed by bodies embedded in a stratified background and extending infinitely in one direction (two-dimensional geometry), With this fully vectorial approach based on the Greens tensor associated with the background, only the embedded scatterers must be discretized, the entire stratified background being accounted for by the Green's tensor. We first derive the formulas for the computation of this dyadic and discuss in detail its physical substance. The utilization of this technique fur the solution of scattering problems in complex structures is then illustrated with tramples from photonic integrated circuits (waveguide grating couplers with varying periodicity).