One simple possibility is to just use concatenation:
text = (r"$RE_{%d}$ = $\frac{\left(\sum^{l_k}{q_m} -\sum^{n}{f_h}\right) " +
r" - |B_t - f_h+f_g)|}{B}$") % num
You could also use triple-quoted multiline strings, but then you need to substitute the line breaks manually:
def lf2space(s):
return " ".join(s.split("\n"))
text = lf2space(r"""
$RE_{%d} =
\frac{\left(\sum^{l_k}{q_m} -\sum^{n}{f_h}\right)
- |B_t - f_h+f_g)|}
{B}$
""" % num)