# Create a line break in a subscript-position term

My code is

\documentclass{article}
\usepackage{amssymb,bm}
$$\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}


And I want to break {s \sim T^{\bm{\pi}}, a \sim \bm{\pi}_{\theta}} into two lines, not put it under \mathbb{E}. In the picture below, how to move the second part after the comma and stack under the first part?

How can I do that? Thank you in advance.

• Off-topic: To "snug up" the \nabla and \theta symbols, consider writing \nabla_{\!\theta}. The \! (negative thinspace) directive moves the subscript term to the left, i.e., closer to the \nabla symbol. – Mico Feb 23 at 6:34
• Possible duplicate of Putting equations under a symbol – Zarko Feb 23 at 12:12

I suggest you do two things:

• Using \DeclareMathOperator, make \E a "math operator"

• Use the \substack macro to break the long line into two parts.

Both of these directives require loading of the amsmath package -- which you may be doing already.

\documentclass{article}
\usepackage{amsmath}  % for '\DeclareMathOperator' and '\substack' macros
\usepackage{amssymb}  % for '\mathbb' macro
\usepackage{bm}       % for '\bm' macro
\DeclareMathOperator{\E}{\mathbb{E}} % define expectations operator
\begin{document}

$$\nabla_{\!\theta} \bm{J}(\theta) = \E_{\substack{s \sim T^{\bm{\pi}}\\ a \sim \bm{\pi}_{\theta}}} [\nabla_{\!\theta} \log\bm{\pi}(a\mid s ) \cdot Q(s,a) ]$$
\end{document}