Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

enter image description here

Is it possible to align the for statements here, without dropping the equation numbers? \hfill and && mess up the placement of the equation numbers for me.

Edit:

Picture of what I get after I tried what was posted as answer

enter image description here

share|improve this question
2  
Providing a minimal working example (MWE) that demonstrates the issue, starting with \documentclass, helps those trying to help you. –  Steven B. Segletes Apr 28 at 13:47

2 Answers 2

up vote 4 down vote accepted

Here is a possible solution (if I understand your request correct):

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\begin{alignat}{2}
  \sum_{\mathclap{p \,=\, 1}}^{i}  s_{tp} - \sum_{\mathclap{p \,=\, 2}}^{i+5}                                       m_{tp} &\leq 0 \qquad
  &&\text{for } i = 1, \dots, 39,\\
  \sum_{\mathclap{p \,=\, i}}^{48} f_{tp} - \sum_{\mathclap{\substack{p \,=\, i-5\\ \hphantom{p \,=\,} -2+1}}}^{46} m_{tp} &\geq 0
  &&\text{for } i = 8, \dots, 48,
\end{alignat}

\end{document}

output

share|improve this answer
    
It's somehow not working for me: I tried this (just a simple version of your answer): `& \sum_{p=i}^{48} f_{tp} - \sum_{\mathclap{p=i-1-2+1}}^{46} m_{tp} \geq 0 \qquad &&\text{ for } i=9,\dots, 48,\\ & \sum_{p=i}^{48} f_{tp} - \sum_{\mathclap{p=i-5-2+1}}^{46} m_{tp} \leq 0 &&\text{ for } i=9,\dots, 48,\`, but the page numbers then moved to a next line. Do you know what could cause that? –  rbm Apr 28 at 16:33
    
I've added a picture of what I get now in the OP. –  rbm Apr 28 at 16:35
    
@rbm: Do you have the fleqn option somewhere in your document? –  Werner Apr 28 at 16:49
    
@Werner Yes I do, I have it with the mathstools package (so \usepackage[fleqn]{mathtools}). Could that cause the problem? –  rbm Apr 28 at 16:50
    
@Werner I got rid of the fleqn now, but then I get a rather similar, still incorrect output with the number on the next line. –  rbm Apr 28 at 16:54

Although a minimal working example (MWE) would really be helpful here, like Steven B. already stated, I think I got you.

Try to use mathtools instead of amsmath. It uses amsmath and extends it more, so you can use the \mathclap command. The lower sum limits of the second summation is causing the gap you dislike:

\documentclass{scrartcl}
\usepackage{mathtools}

\begin{document}
\begin{align}
  \sum_{p=1}^{i}s_{tp} - \sum_{p=2}^{i+5}m_{tp} \leq 0 for i = 1,\cdots,39,\\
  \sum_{p=1}^{48}f_{tp} - \sum_{\mathclap{p=i-5-2+1}}^{46}m_{tp} \geq 0 for i = 8,\cdots,48,
\end{align}
\end{document}
share|improve this answer
    
...where is the alignment around the for as requested? It seems like your post was also cut short. –  Werner Apr 28 at 16:22
    
Thanks, but you did not exactly understand what I meant. My mistake, I should have been more specific in the OP. What I want is the part from for to be aligned somewhat more to the right, all at the same level (like in Sven's answer, but that doesn't work for me yet). –  rbm Apr 28 at 16:38
    
@Werner: I misunderstood his questions, I thought about a different alignment. My mistake, sorry. –  Cheesey Apr 28 at 16:46
    
@Cheesey No problem, I should have been more specific. Do you have an idea what I could change to get it to work (I commented on Sven's solution)? –  rbm Apr 28 at 16:48
    
I have read it. Can you please post the full minimal working example - like Sven and I did - so we can see what usepackages, documentclass, options (like fleqn) etc. you are using? Because I just tested your code in the comments and the numbering works fine for me. –  Cheesey Apr 28 at 16:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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