[Tex/LaTex] breqn package and equation numbering

breqn

I have the following problem with breqn package: I want to write a long equation and automatically split it with dmath environment. It is splitting equation perfectly, but placing the equation number one line below. I want to have a result such that last part of the equation and equation number are in the same line.

Here is the code I'm trying to fix:

\documentclass{article}
\usepackage{breqn}
\begin{document}
\begin{dmath}
{{E}_{0}}\sum\limits_{t=0}^{\infty }\beta _{B}^{t}\left({{D}_{t+1}}+\left( 1+r_{f,t-1} \right)L_{f,t}+\left( 1+r_{g,t-1} \right)L_{g,t}+\left( 1+r_{i,t-1} \right)L_{i,t}-L_{f,t+1}-L_{g,t+1}-L_{i,t+1}-\left( 1+r_{p,t-1} \right){{D}_{t}} -\frac{{{\phi }_{f}}}{2} L_{f,t+1}^{2}-\frac{{{\phi }_{g}}}{2}L_{g,t+1}^{2}-\frac{\phi_{i}}{2}L_{i,t+1}^{2} \right)
\end{dmath}
\end{document}

enter image description here
Thank you.

EDIT: I was told that the space in the second line is not enough to place the equation number. How about following case where I have exactly the same equation given in 3 line with more than enough space to place equation number in the same row:

\documentclass{beamer}
\usetheme{Madrid}
\usepackage{breqn}
\begin{document}
\begin{frame}
\frametitle{Problem}
\begin{dmath}
{{E}_{0}}\sum\limits_{t=0}^{\infty }\beta _{B}^{t}\left({{D}_{t+1}}+\left( 1+r_{f,t-1} \right)L_{f,t}+\left( 1+r_{g,t-1} \right)L_{g,t}+\left( 1+r_{i,t-1} \right)L_{i,t}-L_{f,t+1}-L_{g,t+1}-L_{i,t+1}-\left( 1+r_{p,t-1} \right){{D}_{t}} -\frac{{{\phi }_{f}}}{2} L_{f,t+1}^{2}-\frac{{{\phi }_{g}}}{2}L_{g,t+1}^{2}-\frac{\phi_{i}}{2}L_{i,t+1}^{2} \right)
\end{dmath}
\end{frame}\end{document}

enter image description here

Best Answer

I cannot recommend breqn except when you don't want to bother with typesetting and are willing to accept poor output.

Apparently, the package is not keen into splitting the equation across three lines. Here is a better way to cope with this.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation}
\begin{split}
E_{0}\sum_{t=0}^{\infty }\beta _{B}^{t}
  \biggl(&D_{t+1}+(1+r_{f,t-1})L_{f,t}+(1+r_{g,t-1})L_{g,t} \\
        &+(1+r_{i,t-1})L_{i,t}-L_{f,t+1}-L_{g,t+1}-L_{i,t+1}\\
        &-(1+r_{p,t-1}){{D}_{t}} -\frac{\phi_{f}}{2} L_{f,t+1}^{2}
         -\frac{\phi_{g}}{2}L_{g,t+1}^{2}-\frac{\phi_{i}}{2}L_{i,t+1}^{2}
  \biggr)
\end{split}
\end{equation}

\end{document}

enter image description here