Conflict between subscript and superscript under summation

math-modesubscriptssuperscripts

I would like the subscript of my sum to look better:

$$
\sum_{d \mid p_j^{m_j}} f(d)
$$

creates the output

enter image description here

but i would like the exponent m_j to be further down and closer p_j.

Best Answer

I'd like to suggest that you \smash the subscript term j in p_j. Alternatively, you could \smash the j subscript term in m_j. Optionally, to remove any ambiguity as to where j in p_j belongs, snug it up to the p term via a \! ("negative thinspace") directive.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for \smash[t] macro
\begin{document}
\[
\sum_{d \mid p_{j}^{m_j}} 
\quad\mbox{vs.}\quad
\sum_{d \mid p_{\smash[t]{\!j}}^{m_j}} 
\quad\mbox{vs.}\quad
\sum_{d \mid p_{\!j}^{m_{\smash{j}}}}
\]
\end{document}