36

How can I get an expectation symbol which behaves like $\sum$? Specifically, I want the underscore to be like that of a summation. At the moment I use

$$\mathbb{E}_{x\in A}$$ 

However, I do not like this. It feels like I am writing a sum as

$$\Sigma_{x\in A}$$ 

Whereas the alternative

$$\sum_{x\in A}$$

is much nicer when in a centered equation. (The underscore appears directly below the sigma, instead of slight infront and below.)

Is there a way to make an expectation symbol which behaves like $$\sum$$ rather then $$\Sigma$$?

  • 1
    See this question for finding why you shouldn't use $$ in LaTeX. – egreg May 21 '12 at 12:42
34

Use \mathop{\mathbb{E}} to get math operator spacing and limits behaviour. Or \mathop{{}\mathbb{E}} If you want E to remain on the baseline.

27

If you want "limits" of this operator, e.g., x\in A, always to be typeset as a "subscript" (to the right and below the "E") rather than entirely below the "E" when in display math mode, you may want to use the \DeclareMathOperator instruction that is made available by loading the amsmath or amsopn packages.

Aside: The \mathop directive, in contrast, will make its argument behave exactly like \sum or \prod, in the sense that subscript and superscript arguments will be typeset fully below or above the operator when the directive is processed in display-math mode. Do check out @DavidCarlisle's answer for an application of the \mathop directive to your case.

\documentclass{article}
\usepackage{amsmath,amssymb}
\DeclareMathOperator{\E}{\mathbb{E}}
\begin{document}
$\E_{x\in A}$ and $\displaystyle \E_{x\in A}$
vs.\ $\displaystyle \mathop{\mathbb{E}}_{x\in A}$
\end{document}

enter image description here

Conversely, if you do want the x\in A particle to be typeset entirely below the operator when TeX is in display-math mode, you could use the instruction \DeclareMathOperator* (note the *) instead: \DeclareMathOperator*{\E}{\mathbb{E}}.

  • There is also \DeclareMathOperator* that would avoid the need of using \mathop. – egreg May 21 '12 at 12:58
  • @egreg -- Thanks for that. I'll add a paragraph to mention the "starred" version of the macro. – Mico May 21 '12 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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