14
$\begingroup$

How to show a formula too long to fit in a line?

For example: $$ P(Y-X=m | Y > X) = \sum_{k} P(Y-X=m, X=k | Y > X) = \sum_{k} P(Y-X=m | X=k, Y > X) P(X=k | Y > X) = \sum_{k} P(Y-k=m | Y > k) P(X=k | Y > X).$$

Thanks!

$\endgroup$
3
  • 1
    $\begingroup$ Why downvote this? $\endgroup$
    – Aryabhata
    Commented Mar 19, 2011 at 20:01
  • 3
    $\begingroup$ @Moron: Some people are just pathetic... $\endgroup$
    – Tim
    Commented Mar 20, 2011 at 0:43
  • 2
    $\begingroup$ Let us not jump to conclusions. Perhaps they think they have a valid reason? I am guessing one possible reason could be that it is already in the FAQ (although my brief search didn't bring up any). The downvote could be to encourage searching the FAQ first. Of course, downvoting without commenting is pointless in that case. $\endgroup$
    – Aryabhata
    Commented Mar 20, 2011 at 2:25

3 Answers 3

17
$\begingroup$

Use double dollars and the \begin{align*} environment (within TeX-mode) to solve the problem.

$$\begin{align*} P(Y-X=m | Y > X) &= \sum_{k} P(Y-X=m, X=k | Y > X) \\ &= \sum_{k} P(Y-X=m | X=k, Y > X) P(X=k | Y > X) \\ &= \sum_{k} P(Y-k=m | Y > k) P(X=k | Y > X).\end{align*}$$

$$\begin{align*}
P(Y-X=m | Y > X) &= \sum_{k} P(Y-X=m, X=k | Y > X) \ &= \sum_{k} P(Y-X=m | X=k, Y > X) P(X=k | Y > X) \ &= \sum_{k} P(Y-k=m | Y > k) P(X=k | Y > X).\end{align*}$$

$\endgroup$
10
  • $\begingroup$ What about a case where one has a single long formula which begins with a \left(and ends with a \right)? The align environment seems to fail (in MathJax) for that case. $\endgroup$ Commented Mar 19, 2011 at 17:47
  • 4
    $\begingroup$ @Eric: You can use the invisible \right. to close the left( on the first line and the invisible \left. to open the closing \right) on the last line and make \begin{align}...\end{align} happy. $\endgroup$
    – Isaac
    Commented Mar 19, 2011 at 19:26
  • 1
    $\begingroup$ Actually, the \begin{align*} environment can be used without first going into TeX mode (without the double dollar signs), though it sometimes requires you to escape with extra backslashes to get the interpreter to understand. $\endgroup$ Commented Mar 19, 2011 at 21:13
  • 1
    $\begingroup$ @Eric: the specific problem with \left and \right pairs not working across line breaks is also inherent already in standard TeX, so not a problem with MathJax per se. The usual way to solve the problem is to manually insert \big and similar versions. See en.wikipedia.org/wiki/Help:Displaying_a_formula $\endgroup$ Commented Mar 23, 2011 at 16:11
  • $\begingroup$ @Isaac: But that can give problems because the left bracket and the right bracket don't have to be of the same size! $\endgroup$
    – JT_NL
    Commented Aug 7, 2011 at 11:40
  • 1
    $\begingroup$ One way to get them to be the same size is using the vphantom command. $\endgroup$ Commented Aug 7, 2011 at 14:30
  • $\begingroup$ Oh, I didn't know Isaac's trick. How cool. $\endgroup$
    – davidlowryduda Mod
    Commented Aug 7, 2011 at 20:59
  • $\begingroup$ @AsafKaragila What is the difference between \begin{align*} and \begin{align}? $\endgroup$
    – user93957
    Commented Jan 29, 2014 at 12:42
  • $\begingroup$ @Aðøbe: On this site? None. In general? align* is an unnumbered environment, whereas align is numbered. $\endgroup$
    – Asaf Karagila Mod
    Commented Jan 29, 2014 at 13:04
  • $\begingroup$ @AsafKaragila Thanks! $\endgroup$
    – user93957
    Commented Jan 29, 2014 at 13:05
7
$\begingroup$

Alternatively, since MathJax supports the amsmath extensions, the split environment is also supported:

$$\begin{split}P(Y-X=m | Y > X) &= \sum_{k} P(Y-X=m, X=k | Y > X) \\ &= \sum_{k} P(Y-X=m | X=k, Y > X) P(X=k | Y > X) \\ &= \sum_{k} P(Y-k=m | Y > k) P(X=k | Y > X).\end{split}$$

which is generated by

$$\begin{split} P(Y-X=m | Y > X) &= \sum_{k} P(Y-X=m, X=k | Y > X) \\ &= \sum_{k} P(Y-X=m | X=k, Y > X) P(X=k | Y > X) \\ &= \sum_{k} P(Y-k=m | Y > k) P(X=k | Y > X).\end{split}$$

$\endgroup$
3
  • 1
    $\begingroup$ And nobody pointed out that it would be much nicer to use \mid instead of |... :) $\endgroup$
    – t.b.
    Commented Aug 7, 2011 at 9:56
  • 1
    $\begingroup$ @Theo: ROFL, yes. :D It sucks MathJax doesn't support the \middle to go along with \left and \right though. $\endgroup$ Commented Aug 7, 2011 at 10:14
  • $\begingroup$ Oh, I wasn't aware of that... Hmm. That's probably because I normally use colons for that purpose. $\endgroup$
    – t.b.
    Commented Aug 7, 2011 at 10:24
5
$\begingroup$

As the last mathematician in the world still using Plain TeX, I'd do it with eqalign.

$$\eqalign{P(Y-X=m\mid Y\gt X)&=\sum_kP(Y-X=m,X=k\mid Y\gt X)\cr&=\sum_kP(Y-X=m\mid X=k,Y\gt X)\,P(X=k\mid Y>X)\cr&=\sum_kP(Y-k=m\mid Y\gt k)\,P(X=k\mid Y\gt X)\cr}$$

\eqalign{
  P(Y-X=m\mid Y\gt X)
    &=\sum_kP(Y-X=m,X=k\mid Y\gt X)\cr
    &=\sum_kP(Y-X=m\mid X=k,Y\gt X)\,P(X=k\mid Y>X)\cr
    &=\sum_kP(Y-k=m\mid Y\gt k)\,P(X=k\mid Y\gt X)\cr
}
$\endgroup$
2
  • $\begingroup$ "last mathematician in the world still using Plain $\TeX$" - IIRC, Arturo's another one, so I'm not sure about that claim... :) $\endgroup$ Commented Aug 7, 2011 at 12:52
  • $\begingroup$ Thanks, Theo; thanks, J. M., I'm in good company then. $\endgroup$ Commented Aug 7, 2011 at 22:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .