2

I would like to define the letter \mathbb{E} as a summation symbol for averaged sum.

I've tried the following.

\newcommand{\E}{\mathbb{E}}
$$\E_{x\in X} f(x) = \frac{1}{|X|} \sum_{x\in X}f(x)$$

using newcommand

The problem with this is, that the symbol \mathbb{E} and \sum are not the same size. So then I tried these options (the code isn't pretty, I know that).

\newcommand{\E}{\mathbb{E}}
$$\underset{x \in X}{\scalebox{1.5}{$\E$}} f(x) = \frac{1}{|X|} \sum_{x \in X} f(x).$$

$$\mathop{\scalebox{1.5}{$\E$}}{x \in X} f(x) = \frac{1}{|X|} \sum{x\in X}f(x).$$

$$\scalebox{1.5}{$\E$}{x\in X} f(x) = \frac{1}{|X|} \sum{x\in X}f(x)$$

resizing

While here \mathbb{E} is larger, it is not aligned with summation symbol (at the bottom). Also f(x) is not in the middle of E, as is in for summation symbol.

I also tried the following.

\DeclareMathOperator*{\E}{E}

declare math operator This would be a nice option but it does not accept mathfonts.

Any help would be appriciated, as I am struggling with this for some while now. These are just easy examples, I use average sum a lot in my thesis so I would like to have a nice looking symbol.

Barbara
  • 23

1 Answers1

2

You can use the code in https://tex.stackexchange.com/a/23436/4427 with a suitable coefficient.

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}

\makeatletter \DeclareRobustCommand\bigop[2][1]{% \mathop{\vphantom{\sum}\mathpalette\bigop@{{#1}{#2}}}\slimits@ } \newcommand{\bigop@}[2]{\bigop@@#1#2} \newcommand{\bigop@@}[3]{% \vcenter{% \sbox\z@{$#1\sum$}% \hbox{\resizebox{\ifx#1\displaystyle#2\fi\dimexpr\ht\z@+\dp\z@}{!}{$\m@th#3$}}% }% } \makeatother

\newcommand{\average}{\DOTSB\bigop[0.85]{\mathbb{E}}}

\begin{document}

[ \average_{x\in X}f(x)=\frac{1}{|X|}\sum_{x\in X}f(x) ] \begin{center}% to show what happens inline $\average_{x\in X}f(x)=\frac{1}{|X|}\sum_{x\in X}f(x)$ \end{center}

\end{document}

enter image description here

Never use $$ in LaTeX documents.

egreg
  • 1,121,712