\mathchoice helps to distinguish between math styles:
\mathchoice
{<something in \displaystyle>}
{<something in \textstyle>}
{<something in \scriptstyle>}
{<something in \scriptscriptstyle>}
How would one use \mathchoice to capture the current math style? The following does not work:

\documentclass{article}
\makeatletter
\newcommand{\getmathstyle}{%
\mathchoice
{\global\def\curmathstyle{\displaystyle}}
{\global\def\curmathstyle{\textstyle}}
{\global\def\curmathstyle{\scriptstyle}}
{\global\def\curmathstyle{\scriptscriptstyle}}
}
\makeatother
\begin{document}
\ttfamily
$\getmathstyle$ \meaning\curmathstyle\par
$\displaystyle\getmathstyle$ \meaning\curmathstyle\par
$\scriptstyle\getmathstyle$ \meaning\curmathstyle\par
$\scriptscriptstyle\getmathstyle$ \meaning\curmathstyle
\end{document}



showing that cramped style is active in subscripts and subsubscripts.
\mathchoice, but not to capture the current math style for possible later use. – Werner Oct 24 '12 at 5:27\overtex.stackexchange.com/questions/42855/whats-behind-over/… – David Carlisle Oct 24 '12 at 8:16