# Putting equations under a symbol [duplicate]

My LaTeX code is here

\documentclass{article}

$$\nabla_{\theta} \bm{J}(\theta) = \mathbb{E}_{s \sim T^{\bm{\pi}}, a \sim \bm{\pi}_{\theta}} [\nabla_{\theta} \log \bm{\pi}(a | s ) \cdot Q(s, a) ],$$

\end{document}


How can I put the equation in the red box under $\mathbb{E}$ in order to shorten the length of the output?

• \underset{s \sim T^{\bm{\pi}}{\mathbb{E}} – Henri Menke Feb 23 '19 at 4:56

by use of the stackengine package:
\documentclass{article}
$$\stackMath \nabla_{\theta}\bm{J}(\theta) = \stackunder{\mathbb{E}}{\substack{s\sim T^{\bm{\pi}},\\ a \sim \bm{\pi}_{\theta}}} [\nabla_{\theta}\log\bm{\pi}(a|s) \cdot Q(s,a)],$$