# superscripts in subscripts are too low

The code

%\RequirePackage{fix-cm}%%% makes no difference
\documentclass{standalone}
\usepackage{amsfonts}
%\usepackage{lmodern}%%% makes no difference
\begin{document}
$${}_{N_n^m}$$ $${}_{\mathbb{N}_n^m}$$
\end{document}


produces

The meaning of the term is {1,2,...,n} × ... × {1,2,...,n} (m times), i.e., {1,2,...n}^m. I'm using this term in, say $\bigcup_{b\in\mathbb{N}_n^m} \prod_{i=1}^n \mleft(A_i\setminus\mleft(\bigcup_{\substack{1\le j\le m\\b_j=i}}P^j_i\mright)\mright)$.

For my taste, the letter m is placed too low, apparently unrelated to the height of the preceding N. How to place m on a suitable height in all possible contexts automatically? That is, I'd like to have a macro (say, in LaTeX3) such as

\NewDocumentCommand{\cubeOfNaturals}
{ m m }
{\mathbb{N}\c_math_subscript_token{#1}^{#2}}


except that #2 is placed on a proper height automatically.

• I've posted an answer that works in display, text, script, and scriptscript style. :-) – Mico Dec 5 '16 at 18:03

A trick might be forcing TeX into not using the cramped style:

\documentclass[border=4]{standalone}
\usepackage{amsfonts}

\makeatletter
\newcommand{\cubeOfNaturals}[2]{%
\mathpalette\cube@of@naturals{{#1}{#2}}%
}
\newcommand{\cube@of@naturals}[2]{%
\cube@of@naturals@{#1}#2%
}
\newcommand{\cube@of@naturals@}[3]{%
#1\mathbb{N}_{#2}^{#3}%
}
\makeatother

\begin{document}

$${}_{\cubeOfNaturals{n}{m}}$$ $${}_{\mathbb{N}_n^m}$$

\end{document}


Here's an idea: Insert a "top-smashed" \mathstrut in the superscript position. Specifically, insert a \mathstrut whose height above the baseline has been smashed. Smashing the top of an object (via a \smash[t]{...} directive) leaves the its depth below the baseline unchanged. (Aside: \mathstrut is defined as \vphantom{)}, i.e., it's an invisible object with the height and depth of a round parenthesis.)

\documentclass{article}
\usepackage{amsfonts,mathtools} % mathtools loads amsmath, which provides '\smash[t]' macro
\newcommand{\Nnm}{N_n^{m\smash[t]{\mathstrut}}} % smash away the top of '\mathstrut'
\newcommand{\NNnm}{\mathbb{N}_n^{m\smash[t]{\mathstrut}}}
\begin{document}
$N_n^m$ $\mathbb{N}_n^m$ vs.\ $\Nnm$ $\NNnm$

\bigskip
$\displaystyle \bigcup_{b\in\NNnm} \prod_{i=1}^n \biggl(A_i \setminus \biggl(\,\smashoperator[r]{\bigcup_{\substack{1\le j\le m\\b_j=i}}}P^j_i\biggr)\biggr)$
\end{document}