  We present a theoretical framework for nonlinear optics of graphene and other
2D materials in layered structures. We derive a key equation to find the
effective electric field and the sheet current density in the 2D material for
given incident light beams. Our approach takes into account the effect of the
surrounding environment and characterizes its contribution as a structure
factor. We apply our approach to two experimental setups, and discuss the
structure factors for several nonlinear optical processes including second
harmonic generation, third harmonic generation, and parametric frequency
conversion. Our systematic study gives a strict extraction method for the
nonlinear coefficients, and provides new insights in how layered structures
influence the nonlinear signal observed from 2D materials.
