How do I do something like this:
where the $p\leq x$ and $p\equiv\pmod{q}$ are on separate lines?
You can try this:
\[
\sum_{\shortstack{$p\leq x$\\ $p\equiv a \mod q $ }}
\]
or
\[
\sum_{\begin{aligned} & p\leq x \\ & p\equiv a \pmod q \end{aligned}}
\]
\substack or subarray. Besides, $$ should never be used in LaTeX.
– egreg
Mar 06 '21 at 22:30
\substack{<line_1>\\<line_2>\\...\\<line_n>}as in\[ \sum_{\substack{p \leq x\\p \equiv a \mod q}} \](needs\usepackage{amsmath}). – moewe Mar 06 '21 at 17:07