  We present a methodology for designing metagratings for perfect anomalous
refraction, based on multilayered loaded wire arrays. In recent work, it has
been shown that such structures can implement perfect anomalous deflection and
beam splitting in \emph{reflect-mode}, using only a handful of subwavelength
meta-atoms per (wavelength-scale) macro-period. Extending previous formulations
to enable manipulation of \emph{transmitted} fields as well, we derive
analytical relations between the scattered fields, currents induced on the
wires, and the individual load impedances, and enforce conditions that
guarantee elimination of spurious scattering while retaining a passive and
lossless structure. Utilizing our recent results, we demonstrate how the
multilayered metagratings can be realized using realistic printed-capacitor
loads, whose geometry can be analytically resolved. Thus, this design scheme,
which can be fully implemented in MATLAB, prescribes simple physical
structures, achieving optimal anomalous refraction efficiency without requiring
even a single full-wave simulation. This paves the path for harnessing this
novel concept for applications requiring control on transmitted diffraction
modes (e.g., lenses), taking advantage of an efficient and rigorous design
scheme, and simplified structure.
