I use the even theme.
$$
L=\sum_{(u,v)\in D} \log {\exp(-d(u,v))}
$$
and
$$
-\log {\sum_{v' \in N(u)} \exp(-d(u,v'))}
$$
works but when I combine the two,
$$
L=\sum_{(u,v)\in D} \log {\exp(-d(u,v))}-\log {\sum_{v' \in N(u)} \exp(-d(u,v'))}
$$
It is not outputted as latex. Debugging this thing is also time consuming.