  The behavior in magnetic field of a paramagnetic center is characterized by
its $g$ tensor. An anisotropic form of the latter implies different kind of
response along different crystallographic directions. Here we shed light on the
anisotropy of the $g$ tensor of Yb$^{3+}$ 4$f^{13}$ ions in NaYbS$_2$ and
NaYbO$_2$, layered triangular-lattice materials suggested to host spin-liquid
ground states. Using quantum chemical calculations we show that, even if the
ligand-cage trigonal distortions are significant in these compounds, the
crucial role in realizing strongly anisotropic, `noncubic' $g$ factors is
played by inter-layer cation charge imbalance effects. The latter refer to the
asymmetry experienced by a given Yb center due to having higher ionic charges
at adjacent metal sites within the magnetic $ab$ layer, i.e., 3+ nearest
neighbors within the ab plane versus 1+ species between the magnetic layers.
According to our results, this should be a rather general feature of 4$f^{13}$
layered compounds: less inter-layer positive charge is associated with stronger
in-plane magnetic response.
