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.

In my align* environment I have a bunch of lined up equations, but I would like to put some explanations of the steps done to the right of the equations. Currently it looks bad:

  P(X_l=x_l,\ldots ,X_{l+k}=x_{l+k}) &= \int_0^1 f(x_l)\cdots f(x_{l+k})dp\\
                    &= \int_0^1 \prod_{i=1}^k p^{1\{x_i=1\}}(1-p)^{1\{x_i=0\}}dp\\
                    &= \int_0^1 p^t(1-p)^{k-t}dp\\
                    &= \int_0^1 p^{t+1-1}(1-p)^{k-t+1-1}dp\\
                    &= \dfrac{\Gamma(k-t+1)\Gamma(t+1)}{\Gamma(k+2)}\int_0^1\dfrac{\Gamma(k+2)}{\Gamma(k-t+1)\Gamma(t+1)} p^{t+1-1}(1-p)^{k-t+1-1}dp\\
                    &= \dfrac{\Gamma(k-t+1)\Gamma(t+1)}{\Gamma(k+2)} \text{ \; term on right is a $\Gamma(t+1,k-t+1)$}\\
                    &= \dfrac{t!(k-t)!}{(k+1)!} \text{ \; Since $k$ is an integer}

How would you make this look better? More specifically I think the text would look nice if it was all flushed to the right.

EDIT: How do I make the Latex show up?

share|improve this question
Add && in front of \text and remove the spaces inside it; IMO flushing the conditions to the right margin is not a good idea. –  egreg Nov 3 '12 at 16:34
Hmm, that almost worked, except now the text goes off the page. How could I fix that? –  bdeonovic Nov 3 '12 at 16:36
In this particular case I wouldn't add explanations on the right; this can be useful if all (or most of) the equations have a comment. Since they are just the last two, add the comment in the following text. The big formula in the fifth line doesn't allow anything to be added. –  egreg Nov 3 '12 at 16:41
I see, thank you very much. You can write an answer and I will select it as the answer if you wish. –  bdeonovic Nov 3 '12 at 16:42

1 Answer 1

up vote 4 down vote accepted

In many situations, a comment can be added in the following way:

A &= B && \text{(because pigs fly)} \\
  &= C && \text{(since donkeys are not pigs)} \\
  &= D && \text{(because I say so)}

so that the comments are (left) aligned to each other. However, your case is different: the comment would be only in the last two lines and the fifth one is quite long. The fifth line makes it hard to set the comments so they stick out as such.

Probably the most amenable solution is to defer the comments to the text below the alignment. These are tough decisions, anyway. What about this?

\makebox[2.8em][l]{$\displaystyle P(X_l=x_l,\ldots ,X_{l+k}=x_{l+k})$} \\
  &= \int_0^1 f(x_l)\cdots f(x_{l+k})\,dp\\
  &= \int_0^1 \prod_{i=1}^k p^{1\{x_i=1\}}(1-p)^{1\{x_i=0\}}\,dp\\
  &= \int_0^1 p^t(1-p)^{k-t}dp\\
  &= \int_0^1 p^{t+1-1}(1-p)^{k-t+1-1}\,dp\\
  &= \dfrac{\Gamma(k-t+1)\Gamma(t+1)}{\Gamma(k+2)}\int_0^1\dfrac{\Gamma(k+2)}{\Gamma(k-t+1)\Gamma(t+1)} p^{t+1-1}(1-p)^{k-t+1-1}\,dp\\
  &= \dfrac{\Gamma(k-t+1)\Gamma(t+1)}{\Gamma(k+2)} \\
  &= \dfrac{t!(k-t)!}{(k+1)!}
Notice that the last integral is $\Gamma(t+1,k-t+1)$ and $k$ is an integer.

enter image description here

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.