# How to write two subscripts on top of each other in math mode?

I want to write something like

Q_{a\in A,b\in B}


but with $b\in B$ being below $a \in A$. What is the way to do so?

• P.S. I don't know why but math mode seems not to be working this is why you see the dollars in my question. – Marion Nov 30 '15 at 16:02
• What about using $Q_{a\in A}^{b\in B}$? – Guido Nov 30 '15 at 16:03
• On why math doesn't display here see Why doesn't maths render as maths?. – Alan Munn Nov 30 '15 at 16:14
• – MattAllegro Dec 6 '15 at 16:43

Use \substack:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

$Q_{\substack{a\in A\\b\in B}}$%

\end{document}


Use the \genfrac command from the amsmath package.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
Q_{\genfrac{}{}{0pt}{}{a\in A}{b\in B}}
\end{equation*}
\end{document}