We study the magnetic resonant x-ray scattering (RXS) spectra around the K
edge of Cu in KCuF3 on the basis of an {\em ab initio} calculation. We use
the full-potential linearlized augmented plane wave method in the LDA+U
scheme, and introduce the lattice distortion as inputs of the calculation.
We obtain finite intensity on magnetic superlattice spots, about three orders
of magnitude smaller than on orbital superlattice spots, by taking account of
the spin-orbit interaction (SOI). No intensity appears without the SOI,
indicating that the intensity arises not from the spin polarization but from
the orbital polarization in 4p states. The present calculation reproduces
well the experimental spectra as functions of photon energy and of azimuthal
angle. We also calculate the RXS intensity on orbital superlattice spots. It is
found that the intensity increases with increasing Jahn-Teller distortion. The
spectra remain nearly the same in the nonmagnetic state given by the simple
LDA, in which the orbital polarization in the 3d states is much smaller. This
strongly suggests that the intensity on orbital spots is mainly controlled by
the lattice distortion, not by the 3d orbital order itself.Comment: 7 pages, 8 figures, Submitted to PRB, RevTeX