Critical parameter for spatially inhomogeneous slabs