2

How do I get the last equation (6.24) to align to the right...?

See my current code below.

enter image description here

enter image description here

Gonzalo Medina
  • 505,128
  • 3
    Posting a copy/pastable version of your code, rather than an image of your code, is what is needed to help resolve your issues. Welcome to the site. Ideally, a minimum working example, starting with \documentclass, is best, as it does not ask the site users to recreate that which you could conveniently provide. – Steven B. Segletes Aug 12 '15 at 13:29
  • 2
    Welcome to TeX.sx! Instead of posting a picture of your code it would rather be helpful if you posted your code directly – cgnieder Aug 12 '15 at 13:29
  • 4
    Can't you just add &s until (probably another two or three) the equation is right-aligned? – moewe Aug 12 '15 at 13:31
  • @moewe Can you give an answer? – egreg Sep 11 '15 at 14:11
  • @egreg Done! Feel free to comment. – moewe Sep 11 '15 at 15:28

2 Answers2

2

You may want to refer to Difference between align and alignat environments and egreg's answer here for a primer on alignat.

Basically there are alternating right and left aligned columns and you use the & to move the terms right one column. You want to move the s \in \simset{1,\dots,S} term right, so in the end it should (in total) have as many &s before it in the line as the \forall b \in \simset{1,\dots,B} from the first line.

Spacing has to be done manually with alignat. But you can also use align, where we don't have to do the spacing ourselves.

So you probably want

\begin{alignat}{2}
  & \sum_{t=1}^T x^{b,t} \leq 1                      &\forall b \in \simset{1,\dots,B}\\
  & \sum_{t=1}^T x^{b,t} \cdot MT^b \leq MMC         &\forall t \in \simset{1,\dots,T}\\
  & \sum_{t=1}^T x^{\tilde{b},t} \cdot PT^q \leq MPC &\forall \tilde{b} \in \simset{1,\dots,B}\\
  & \sum_{t=1}^k x^{p,t}  \leq \sum_{t=1}^k x^{j,t}  &\forall (p,j) \in E, \forall k \in \simset{1,\dots,B}\\
  &  x^{b,t} \in\simset{0,1}                         &\forall b \in \simset{1,\dots,B}, \forall t \in \simset{1,\dots,T}\\
  &                                                  &s \in \simset{1,\dots,S}
\end{alignat}

where I don't think any further manual spacing is needed.

enter image description here

With align

\begin{align}
  & \sum_{t=1}^T x^{b,t} \leq 1                      &\forall b \in \simset{1,\dots,B}\\
  & \sum_{t=1}^T x^{b,t} \cdot MT^b \leq MMC         &\forall t \in \simset{1,\dots,T}\\
  & \sum_{t=1}^T x^{\tilde{b},t} \cdot PT^q \leq MPC &\forall \tilde{b} \in \simset{1,\dots,B}\\
  & \sum_{t=1}^k x^{p,t}  \leq \sum_{t=1}^k x^{j,t}  &\forall (p,j) \in E, \forall k \in \simset{1,\dots,B}\\
  &  x^{b,t} \in\simset{0,1}                         &\forall b \in \simset{1,\dots,B}, \forall t \in \simset{1,\dots,T}\\
  &                                                  &s \in \simset{1,\dots,S}
\end{align}

Or maybe you even want alignment at the first relation sign

\begin{alignat}{2}
  \sum_{t=1}^T x^{b,t}                     &\leq 1
    &\forall b \in \simset{1,\dots,B}\\
  \sum_{t=1}^T x^{b,t} \cdot MT^b          &\leq MMC
    &\forall t \in \simset{1,\dots,T}\\
  \sum_{t=1}^T x^{\tilde{b},t} \cdot PT^q  &\leq MPC
    &\forall \tilde{b} \in \simset{1,\dots,B}\\
  \sum_{t=1}^k x^{p,t}                     &\leq \sum_{t=1}^k x^{j,t}
    &\forall (p,j) \in E, \forall k \in \simset{1,\dots,B}\\
  x^{b,t}                                  &\in\simset{0,1}
    &\quad\forall b \in \simset{1,\dots,B}, \forall t \in \simset{1,\dots,T}\\
                                           &
    &s \in \simset{1,\dots,S}
\end{alignat}

Where I found it necessary to insert at least a \quad in line (11).

enter image description here

Or with align

\begin{align}
  \sum_{t=1}^T x^{b,t}                     &\leq 1
    &\forall b \in \simset{1,\dots,B}\\
  \sum_{t=1}^T x^{b,t} \cdot MT^b          &\leq MMC
    &\forall t \in \simset{1,\dots,T}\\
  \sum_{t=1}^T x^{\tilde{b},t} \cdot PT^q  &\leq MPC
    &\forall \tilde{b} \in \simset{1,\dots,B}\\
  \sum_{t=1}^k x^{p,t}                     &\leq \sum_{t=1}^k x^{j,t}
    &\forall (p,j) \in E, \forall k \in \simset{1,\dots,B}\\
  x^{b,t}                                  &\in\simset{0,1}
    &\forall b \in \simset{1,\dots,B}, \forall t \in \simset{1,\dots,T}\\
                                           &
    &s \in \simset{1,\dots,S}
\end{align}

The need for manual spacing vanishes here.

Full MWE (including the definition of the mysterious \simset)

\documentclass{article}
\usepackage{mathtools}
\DeclarePairedDelimiter{\simset}{\{}{\}}


\begin{document}
\begin{alignat}{2}
  & \sum_{t=1}^T x^{b,t} \leq 1                      &\forall b \in \simset{1,\dots,B}\\
  & \sum_{t=1}^T x^{b,t} \cdot MT^b \leq MMC         &\forall t \in \simset{1,\dots,T}\\
  & \sum_{t=1}^T x^{\tilde{b},t} \cdot PT^q \leq MPC &\forall \tilde{b} \in \simset{1,\dots,B}\\
  & \sum_{t=1}^k x^{p,t}  \leq \sum_{t=1}^k x^{j,t}  &\forall (p,j) \in E, \forall k \in \simset{1,\dots,B}\\
  &  x^{b,t} \in\simset{0,1}                         &\forall b \in \simset{1,\dots,B}, \forall t \in \simset{1,\dots,T}\\
  &                                                  &s \in \simset{1,\dots,S}
\end{alignat}

\begin{align}
  & \sum_{t=1}^T x^{b,t} \leq 1                      &\forall b \in \simset{1,\dots,B}\\
  & \sum_{t=1}^T x^{b,t} \cdot MT^b \leq MMC         &\forall t \in \simset{1,\dots,T}\\
  & \sum_{t=1}^T x^{\tilde{b},t} \cdot PT^q \leq MPC &\forall \tilde{b} \in \simset{1,\dots,B}\\
  & \sum_{t=1}^k x^{p,t}  \leq \sum_{t=1}^k x^{j,t}  &\forall (p,j) \in E, \forall k \in \simset{1,\dots,B}\\
  &  x^{b,t} \in\simset{0,1}                         &\forall b \in \simset{1,\dots,B}, \forall t \in \simset{1,\dots,T}\\
  &                                                  &s \in \simset{1,\dots,S}
\end{align}

\begin{alignat}{2}
  \sum_{t=1}^T x^{b,t}                     &\leq 1
    &\forall b \in \simset{1,\dots,B}\\
  \sum_{t=1}^T x^{b,t} \cdot MT^b          &\leq MMC
    &\forall t \in \simset{1,\dots,T}\\
  \sum_{t=1}^T x^{\tilde{b},t} \cdot PT^q  &\leq MPC
    &\forall \tilde{b} \in \simset{1,\dots,B}\\
  \sum_{t=1}^k x^{p,t}                     &\leq \sum_{t=1}^k x^{j,t}
    &\forall (p,j) \in E, \forall k \in \simset{1,\dots,B}\\
  x^{b,t}                                  &\in\simset{0,1}
    &\quad\forall b \in \simset{1,\dots,B}, \forall t \in \simset{1,\dots,T}\\
                                           &
    &s \in \simset{1,\dots,S}
\end{alignat}

\begin{align}
  \sum_{t=1}^T x^{b,t}                     &\leq 1
    &\forall b \in \simset{1,\dots,B}\\
  \sum_{t=1}^T x^{b,t} \cdot MT^b          &\leq MMC
    &\forall t \in \simset{1,\dots,T}\\
  \sum_{t=1}^T x^{\tilde{b},t} \cdot PT^q  &\leq MPC
    &\forall \tilde{b} \in \simset{1,\dots,B}\\
  \sum_{t=1}^k x^{p,t}                     &\leq \sum_{t=1}^k x^{j,t}
    &\forall (p,j) \in E, \forall k \in \simset{1,\dots,B}\\
  x^{b,t}                                  &\in\simset{0,1}
    &\forall b \in \simset{1,\dots,B}, \forall t \in \simset{1,\dots,T}\\
                                           &
    &s \in \simset{1,\dots,S}
\end{align}
\end{document}
moewe
  • 175,683
1

Something like this?

enter image description here

Well, I'm not retype your code from given picture. This will should be easy to you. MWE below show the principle, how to format it to achieve above picture.

    \documentclass{article}
    \usepackage{amsmath}

    \begin{document}
\begin{equation}
    P\max \sum_1\sum_2\sum_3 \frac{1}{S} x^{b,t} v^b d^t
\end{equation}
s.t.
\begin{align}
    &   \sum_1 a    &   b\in\{1,\dots,B\}               &   \\ 
    &   \sum_1 b    &   \text{longer conditions}        &   \\
    &   \sum_1 c    &   \text{the longest conditions}   &   
\end{align}
    \end{document}
Zarko
  • 296,517