  Let $f$ be a newform of weight $2k$ and let $\chi$ be an unramified imaginary
quadratic Hecke character of infinity type $(2t, 0)$, for some integer $0 < t
\leq k-1$. We show that the central derivative of the Rankin-Selberg
$L$-function $L(f,\chi,s)$ is, up to an explicit positive constant, equal to
the Beilinson-Bloch height of a generalized Heegner cycle. This generalizes the
Gross-Zagier formula (the case $k = 1$) and Zhang's higher weight formula (the
case $t=0$).
