[Tex/LaTex] Aligning multiple column equation on left

alignalignatamsmath

I would like some equations aligned to the left, inline with text, with equation numbers aligned to the right, and with a middle column aligned with itself.

The solution here and other solutions using alignat do not appear to provide left alignment with text. I also do not want to use the document class fleqn, as it affects the look of other equations.

Below I have successfully gotten the look I'm after, but by creating two different flalign objects, and this leaves an ugly space between the two. I would prefer one flalign object, for neatness and to remove the gap.

\documentclass[journal]{IEEEtran}
\usepackage[cmex10]{amsmath}
\begin{document}
\begin{flalign}
\text{minimize} \; cost =&\sum\limits_{g,t} {{\lambda _{g,t}}p_{g,t}^{sch}} \label{7} & \\
&+ \sum\limits_t {{\lambda ^{shed}}c_t^{shed}} &\nonumber \\
&- \sum\limits_t {{\lambda ^{spill}}w_t^{spill}} &\nonumber
\end{flalign}
\begin{flalign}
& \text{s.t.} \nonumber &\\
& \sum\limits_g {p_{g,t}^{sch}}  + w_{t}^{DA} - w_{t}^{spill} + c_{t}^{shed} = {c_{t}^{DA}} &&\forall t \label{8} &\\
& p_{g,t}^{sch} \ge P_g^{\min } && \forall g,t \label{9} &\\
\end{flalign}
\end{document}

Here is the output:

screenshot of tex output

This is the closest I've gotten when making a single flalign object:

\begin{flalign}
\text{minimize} \; cost =&\sum\limits_{g,t} {{\lambda _{g,t}}p_{g,t}^{sch}} \label{7} && \\
&+ \sum\limits_t {{\lambda ^{shed}}c_t^{shed}} \nonumber \\
&- \sum\limits_t {{\lambda ^{spill}}w_t^{spill}} \nonumber \\
\text{s.t.} \nonumber &&\\
& \sum\limits_g {p_{g,t}^{sch}}  + w_{t}^{DA} - w_{t}^{spill} + c_{t}^{shed} = {c_{t}^{DA}} &&\forall t \label{8} \\
& p_{g,t}^{sch} \ge P_g^{\min } && \forall g,t \label{9}
\end{flalign}

and the output (I would like equations 8 & 9 to line up with the minimize cost text on the left):

single flalign object

Any help much appreciated!

Best Answer

Do you looking for something like this?

\documentclass[journal]{IEEEtran}
\usepackage[cmex10]{amsmath,mathtools}% mathtools added for multline environment
\usepackage[active,pdftex,displaymath,tightpage]{preview}% just for showing equation
\begin{document}
    \begin{flalign}
\text{minimize} \; cost =
    &\sum\limits_{g,t} {{\lambda _{g,t}}p_{g,t}^{sch}} \label{7}    &   \\
    &+ \sum\limits_t {{\lambda ^{shed}}c_t^{shed}}                  &   \nonumber \\
    &- \sum\limits_t {{\lambda ^{spill}}w_t^{spill}}                &   \nonumber
\intertext{s.t.}
    &   \begin{multlined}[b]
        \sum\limits_g {p_{g,t}^{sch}}  + w_{t}^{DA} - \\    
        \quad   w_{t}^{spill} + c_{t}^{shed} = {c_{t}^{DA}}% this is to long for one line
        \end{multlined}                 &&\forall t                 &   \label{8}    \\
    & p_{g,t}^{sch} \ge P_g^{\min }     && \forall g,t              &   \label{9} 
    \end{flalign}
\end{document}

enter image description here

Related Question