5

Possible Duplicate:
Linebreak in equations

I am very new to latex, its been a super frustrating I spend almost close to two hours on getting a new line inside the math block

\[{P(g(X) \neq Y |X = x) = 1 − P (Y = g(X)|X = x)}
{= 1 - [P(Y=1,g(X)=1|X=x) + P(Y=1,g(X)=1|X=x)]}
{= 1 − E[1_{Y =1} 1_{g(X)=1}|X = x] + E[1_{Y =0} 1{g(X)=0}|X = x]}
\]

Also I used underscores to show the subscript but somehow that doesn't work either.

It would be great if someone could give a pointer.

1 Answers1

6

Use a multiline environment from the amsmath package, like align:

\begin{align*}
\{P(g(X)\neq& Y \mid X=x) = 1-P(Y=g(X)\mid X=x)\}\\
\{=& 1 - [P(Y=1,g(X)=1\mid X=x)\\
&+ P(Y=1,g(X)=1\mid X=x)]\}\\
\{=& 1 - E\left[1_{Y =1} 1_{g(X)=1}\mid X = x\right]\\
&+ E\left[1_{Y =0} 1{g(X)=0}\mid X = x\right]\}
\end{align*}

If you don't want your equation numbered, use align* instead of align.

Instead of directly using the amsmath package, you can instead use mathtools. It tries to fix some bugs in amsmath and provides additional symbols and options to change the layout of equations.

David Carlisle
  • 757,742
Juri Robl
  • 4,763