[Tex/LaTex] Make equation number in middle with left alignment in latex

alignmentequations

I need to place the following bulk of equation to left alignment with keeping the equation number in the middle, however using flalign require set option on/off by line for equation number which at last will not be in the middle.

 \begin{flalign}
    \ell_1(\bm{\phi})& =\sum_{i=1}^{N-N^*} \sum_{j=2}^{d_i-1} ln(1- 
    \bm{P}_{ij}),&\nonumber\\
    \ell_2(\bm{\phi})& =\sum_{i=1}^{N-N^*} ln\,\bm{P}_{id_i},&
 \end{flalign}

On the other hand, when using aligned with equation, equation number will be in the middle but the whole bulk of equation moved to center.

\begin{equation}
 \begin{aligned}
    \ell_1(\bm{\phi})& =\sum_{i=1}^{N-N^*} \sum_{j=2}^{d_i-1} ln(1- 
    \bm{P}_{ij}),\\
    \ell_2(\bm{\phi})& =\sum_{i=1}^{N-N^*} ln\,\bm{P}_{id_i},
 \end{aligned}
\end{equation}

How can I keep the equation left aligned with equation number in the middle.

Best Answer

It's not clear why a particular equation should be left aligned. If you want all equations to be left aligned, use the fleqn option.

Anyway, here's a way with flalign.

Function names such as “ln”, “sin”, “exp” should be typed in with a backslash: \ln and so on; this will give the correct spacing, besides using upright font shape.

\documentclass{article}
\usepackage{amsmath,bm}

\usepackage[nopar]{lipsum} % for context

\begin{document}

\lipsum[4]
\begin{flalign}
& \begin{aligned}
    \ell_1(\bm{\phi})& =\sum_{i=1}^{N-N^*} \sum_{j=2}^{d_i-1} \ln(1-\bm{P}_{ij}),\\
    \ell_2(\bm{\phi})& =\sum_{i=1}^{N-N^*} \ln\bm{P}_{id_i},
 \end{aligned}
&&
\end{flalign}
\lipsum[4]

\end{document}

enter image description here