4

My code is

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

\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?

enter image description here

How can I do that? Thank you in advance.

Mico
  • 506,678

1 Answers1

5

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.

enter image description here

\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}

\begin{equation}
\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{equation}
\end{document}
Mico
  • 506,678