I find it cumbersome to typeset \({\mathbb E}[x]\), “the expectation of x”, in LaTeX. I’ve simplified the code a little.
First, include these lines in the header of your document:
\usepackage{amsmath}
\usepackage{amsfonts}
\newcommand{\e}[1]{{\mathbb E}\left[ #1 \right]}
This calls on the necessary packages and makes a new function \e which takes one argument. The outcome is that argument within appropriately-sized square brackets and prefaced with the expectation sign.
For example, the code \e{x^2}=10 results in \({\mathbb E}[x^2]=10\).
2 thoughts on “LaTeX mathematical expectation shortcut”
Thanks for your code.
I could use similar code for probability symbol right?
Yep, you sure can.