TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following snipped in my LaTeX document:

  \sum_{j=1}^{m}x_{ij} &= 1 \text{ for } i = 1,2,...,n
  \sum_{i \in P_k}x_{ij} &\leq 1 \text{ for } j = 1,2,...,m \text{; } \forall k

As you can see, the = and \leq are aligned, and there is some conditional text after the RHS of each equation.

As it turns out, the conditional text is also aligned, but only because both RHS's are equal. If my top RHS was equal to, say, 100 and the bottom was 1, then the conditional text would be offset.

I have two questions:

  1. How can I align two things at once? I would like the equation to be aligned on the (in)equality, but I also want the conditions to be aligned.
  2. How can I keep the equations more-or-less centred on the page, but have the conditional text off towards the right of the page (but still aligned based on their start location.


This is what I have now:

a(10i) = b for all i
  b(j) = a for all j

however this can happen with the way I have it currently laid out:

a(10i) = b for all i
  b(j) = a/10 for all j

notice that the different length RHS pushes the condition off.

What I'd like is something like:

a(10i) = b                for all i
   b(j) = a/10            for all j

with the equations centred on the page if possible.

Also, if I change the conditional text so they're variable lengths, then they should start at the same point:

a(10i) = b                for all i
  b(j) = a/10             for all j > 5

Notice that the equations are centred on the page and aligned on the equality, and the conditions are off towards the right, but still aligned from their start location.

share|improve this question
The simplest would be to use \phantoms{}. So for the case where you had the 100, in the line below I would just use \phantom{00}1. Here is a recent answer I gave that has some details about \phantoms: Aligned, hanging indents in non-monospaced code. – Peter Grill Feb 10 '12 at 2:24
up vote 10 down vote accepted

How does the following look?

  \alpha+\beta\sum_{j=1}^{m}x_{ij}  &=1&     &\text{for}\ i = 1,2,\ldots,n\\
  \sum_{i \in P_k}x_{ij}            &\leq1&  &\text{when}\ j = 1,2,\ldots,m \text{;}\ \forall k

enter image description here

share|improve this answer
This works beautifully, but my equation numbers have disappeared from my output pdf and I'm getting an error: Package amsmath Error: Multiple \label's: label 'eqFirstSum' will be lost, and then I'm getting warnings that my 2 labels are undefined. – Ozzah Feb 10 '12 at 3:29
Just remove the stars from the beginning and end statements. I just put those in because I felt the equation numbers added nothing to the above image. Compile a couple of times after to get all the references correct in the output. – qubyte Feb 10 '12 at 3:56
Works great. Thanks! – Ozzah Feb 10 '12 at 4:00
You're very welcome. :) – qubyte Feb 10 '12 at 4:02
@Ozzah: By the way, use \ldots (or \dotc) instead of typing the dots verbatim .... – Werner Feb 10 '12 at 5:34

The way to have the conditions aligned is as follows:


    \sum_{j=1}^{m}x_{ij} &= 1 & \text{ for } i &= 1,2,...,n
    \sum_{i \in P_k}x_{ij} &\leq 1 & \text{ for } j &= 1,2,...,m \text{; } \forall k
    \sum_{i \in P_k}x_{ij} &\leq 1 & 
    \sum_{i \in P_k}x_{ij} &\leq 1 & \text{ for } j &= 1,2,...,m \text{; } \forall k

First method

I hope that this example answers your second question as well. Though I have no idea whether it would be possible to align everything using different align environments. As I understand, the amount of free space on the right depents on how much space do you want to leave for the conditions.

You can also use the alignat environment. It is slightly more flexible at aligning things :)

    \sum_{j=1}^{m}x_{ij} &= 1 && \text{ for } i = 1,2,...,n
    \sum_{i \in P_k}x_{ij} &\leq (1 - \sqrt{23}) && \text{ for } j = 1,2,...,m \text{; } \forall k
    \sum_{i \in P_k}x_{ij} &\leq 1 && 
    \sum_{i \in P_k}x_{ij} &\leq 1 && \text{ for } j = 1,2,...,m \text{; } \forall k

Second method

Hope that helps :) You can read about it on the amsmath documentation

share|improve this answer

Your Answer


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.