0

I currently have the following output:

enter image description here

I want to align the equals signs even after the bit of text. Is there a nice way to do this besides having one big align block and putting the text inside it? (The code is below if needed.)

We have

\begin{align*}
\mathbb{E}X &= \sum_{k=0}^\infty k\mathbb{P}(k)\\
&=\sum_{k=0}^\infty k\frac{\lambda}{k!}e^{-\lambda}\\
&=\lambda e^{\lambda}\sum_{k=0}^\infty k\frac{1}{k!}\\
&=\lambda e^{\lambda}\sum_{k=1}^\infty (k-1)\frac{1}{(k-1)!}.
\end{align*}

Performing the change of variable $j=k-1$ we then get

\begin{align*}
&=\lambda e^{\lambda}\sum_{j=0}^\infty j\frac{1}{j!}\\
&=\lambda e^{-\lambda}e^\lambda\\
&=\lambda.
\end{align*}

Edit: Also please ignore the typos in the equation itself, I just hastily copied down an example :)

1
  • That's what \intertext is for. Beware: never leave a blank line before a math display.
    – egreg
    Sep 29 at 9:40

1 Answer 1

1

I suppose that this is what you are after:

\documentclass{report}
\usepackage{amsmath}
\usepackage{amsfonts}
\begin{document}
\begin{align*}
\mathbb{E}X &= \sum_{k=0}^\infty k\mathbb{P}(k)\\
&=\sum_{k=0}^\infty k\frac{\lambda}{k!}e^{-\lambda}\\
&=\lambda e^{\lambda}\sum_{k=0}^\infty k\frac{1}{k!}\\
&=\lambda e^{\lambda}\sum_{k=1}^\infty (k-1)\frac{1}{(k-1)!}.\\
\intertext{Performing the change of variable $j=k-1$ we then get}
&=\lambda e^{\lambda}\sum_{j=0}^\infty j\frac{1}{j!}\\
&=\lambda e^{-\lambda}e^\lambda\\
&=\lambda.
\end{align*}
\end{document}

The output will be:

enter image description here

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