2

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!

  • 1
    if you want the last two lines flush left, then you should omit the & (the alignment point) at the left. since the line (8) is wider than the text "minimum cost", you will need to make it look shorter; you can do that with \rlap{$\displaystyle ... $} (or \mathrlap, which requires mathtools). the line "s.t." is best presented with \shortintertext{...} (also requiring \mathtools). – barbara beeton Sep 30 '14 at 14:59
2

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

| improve this answer | |
1

I can propose this, in which the two conditions are not numbered independently. I took the liberty to change your texttual exponents to \mathrm (as you typed it, for instance, ‘shed’ looks like the product of the four variables s, h, e, d. Also you don't need to write \limits since you're in a display enviromnent. Finally, I loaded mathtools instead of amsmath, to use the shortintertext command.

\documentclass[journal]{IEEEtran}
\usepackage[cmex10]{mathtools}
\usepackage{cases}

\begin{document}

\begin{flalign}
 & \text{minimize} \; \mathrm{cost}=∑_{g,t} {{λ _{g,t}}p_{g,t}^\mathrm{sch}}
\begin{aligned}[t] &+ ∑_t {{λ ^\mathrm{shed}}c_t^\mathrm{shed}}\label{7} \\
 & - ∑_t λ ^\mathrm{spill} w_t^\mathrm{spill}
 \end{aligned} \\
 & \begin{aligned}\text{s.t.}\enspace & \bullet\enspace
 ∑_g {p_{g,t}^\mathrm{sch}} + w_{t}^{DA} - w_{t}^\mathrm{spill} + c_{t}^\mathrm{shed} = {c_{t}^{DA}} & ∀ t \\
 & \bullet\enspace p_{g,t}^\mathrm{sch} ≥ P_g^{\min } & ∀ g, t
 \end{aligned}
\end{flalign}

\end{document} 

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.