A better expectation operator which plays nicely with undersetting?
You can use the model of \int
for this:
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand{\E}{\operatorname*{\mathbf{E}}\ilimits@}
\makeatother
\begin{document}
\[
\iint_{R} f(x, y)\, dx \, dy \qquad \text{versus} \qquad \iint\limits_{R} f(x, y) \, dx \, dy
\]
\[
\E_{R} f(X, Y) \qquad \text{versus} \qquad \E\limits_{R} f(X, Y)
\]
\end{document}
Using \ilimits@
will make the command obey the intlimits
option just like \int
.
Use \nolimits
instead of \ilimits@
if you don't want that.
For some reason, \DeclareMathOperator
will not react to \limits
. However, \DeclareMathOperator*
will react to \nolimits
. So this should give you the result you are lookiing for:
\DeclareMathOperator*{\E}{{}\bf E}
\[
\E\nolimits_{R} f(X, Y) \qquad \mbox{versus} \qquad \E_{R} f(X, Y)
\]
For technical reasons, I'm not able to show output. (Since retiring from AMS, I have lost access to all my previous resources, and haven't yet rebuilt a working system.)
The presence of the {}
in the definition is intended to counteract the default positioning of a single character as an operator to be vertically centered on the math axis. This is the default (specified in Appendix G of the TeXbook) so that operators such as \sum
, \int
, etc., are properly positioned.
The inability of the unstarred \DeclareMathOperator
to react to \limits
seems unreasonable, so I will make a request for it to be implemented in a future release of amsopn
.
Update. I have been urged to check the documentation in amsopn.dtx
, and there I find that \limits
has been purposely inhibited, as pointed out by @egreg. I therefore withdraw the suggestion that it be made available.
Your first operator works the other way:
\documentclass[preview]{standalone}
\usepackage{amsmath}
\DeclareMathOperator*{\E}{\mathbf E}
\DeclareMathOperator{\EE}{\mathbf E}
\newcommand{\EEE}{\mathop{{\mathbf E}}}
\begin{document}
\[
\iint_{R} f(x, y)\, dx dy \qquad \mbox{versus} \qquad \iint\limits_{R} f(x, y) \, dx dy
\]
\[
\E_{R} f(X, Y) \qquad \mbox{versus} \qquad \E\nolimits_{R} f(X, Y)
\]
\end{document}