# Place subscript below math operator and its following symbols

I'm dealing with equations from statistics that include expectations over quite long expressions. To display those without too many line breaks, I'd like to place the subscript below the operator and its arguments.

### Normal subscript

\newcommand{\E}[]{\mathbb{\operatorname{E}}_{#2}#1[#3#1]}
\E{q(s_{t-1} \mid o_{\leq t},a_{<t})}{p(s_t \mid s_{t-1},a_{t-1})} ### Subscript below

This related question describes how to use \mathop{} to place the subscript underneath the operator. However, the large space around the operator takes up too much space.

\newcommand{\E}[]{\mathop{\mathbb{E}}_{#2}#1[#3#1]}
\E{q(s_{t-1} \mid o_{\leq t},a_{<t})}{p(s_t \mid s_{t-1},a_{t-1})} I've also found this related question about left aligning the subscript but it still introduces a lot of space to the right of the operator.

### Desired outcome

Here is an example of how I'd like the subscript to behave. Is should be left-aligned below the operator without creating additional spacing to the right of the operator. ## 1 Answer

Based on this recent answer, I'd suggest

\documentclass{article}
\usepackage{amsfonts}
\usepackage{mathtools}
\newlength\mywdE
\newcommand{\E}[]{\settowidth\mywdE{$\mathbb{E}$}
\mathop{\mathbb{E}}_{\mathmakebox[0.5\mywdE][l]{#2}}#1[#3#1]}
%
\begin{document}
$\E{q(s_{t-1} \mid o_{\leq t},a_{<t})}{p(s_t \mid s_{t-1},a_{t-1})}$
\end{document} You can e.g. use a \vphantom to move the subscript down.

\documentclass{article}
\usepackage{amsfonts}
\usepackage{mathtools}
\newlength\mywdE
\newcommand{\E}[]{\settowidth\mywdE{$\mathbb{E}$}
\mathop{\mathbb{E}}_{\vphantom{|^|}\mathmakebox[0.5\mywdE][l]{#2}}#1[#3#1]}
%
\begin{document}
$\E{q(s_{t-1} \mid o_{\leq t},a_{<t})}{p(s_t \mid s_{t-1},a_{t-1})}$
\end{document} • Thanks a lot! How would I move the subscript a bit further down to avoid overlaps, while keeping the spacing to the line below (to not create new overlap there)? – danijar Nov 30 '18 at 4:01
• @danijar I added a possible way. – user121799 Nov 30 '18 at 4:07