2

This is very similar to a lot of other questions but I haven't found one that EXACTLY replicates the problem I'm having. I have the following:

\begin{align*}
  &\text{minimize} &R_k + \sum_jr_{jk}^+ + r_{jk}^- &\\
  &\text{subject to} &R_k + r_{jk}^+ \geq \hat{\gamma_{jk}}X_jk, &\forall j ,k\\
  & &R_k + r_{jk}^- \geq -\hat{\gamma_{jk}}X_jk, &\forall j,k \\
  & &R_k, r_{jk}^+, r_{jk}^- \geq 0 &\forall j,k
\end{align*}

Ultimately I want my output to have the text line up in the "first column", the R_k values to line up in the second column, and all the forall statements to line up in the third. Note that none of the lines have all three items (i.e. the last two should have some leading white space).

Right now my output has the text and the forall's lining up but the R_k terms are scattered. Any help is appreciated

migrated from stackoverflow.com Jul 15 '13 at 21:05

This question came from our site for professional and enthusiast programmers.

  • Welcome to TeX.sx! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Jul 15 '13 at 21:22
5

In the align and align* environments, columns are alternately justified right, left, right, left, etc. If you want two adjacent columns to both be aligned left (or right), use && rather than & to separate them. This might be closer to what you're looking for:

\begin{align*}
 & \text{minimize}   && R_k + \sum_jr_{jk}^+ + r_{jk}^-             &&             \\
 & \text{subject to} && R_k + r_{jk}^+ \geq  \hat{\gamma_{jk}}X_jk, && \forall j,k \\
 &                   && R_k + r_{jk}^- \geq -\hat{\gamma_{jk}}X_jk, && \forall j,k \\
 &                   && R_k,  r_{jk}^+, r_{jk}^- \geq 0             && \forall j,k
\end{align*}

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.