Command for fontsize-dependent code selection

I have heard of a LaTeX-command which provides font-dependent code selection in math mode, but I forgot the name of it and cannot find it – Here is what I mean:

\unknownCommand{display size code}{text size code}{script size code}{scriptscript size code}


so that one could write

$\unknownCommand{...}$ % => outputs "display size code"
$e^{\unknownCommand{...}}$ % => outputs "script size code"


Do you know what command it is?

• – egreg Apr 25 '13 at 9:37

  \mathchoice{display}{text}{script}{scriptscript}

But beware \mathchoice is one of the most weird and hard to use parts of TeX, it always typesets all four branches and TeX makes a decision much later when converting the math list into a horizontal list as to which branch to use. (This is to support the unfortunate syntax of the \over primitive which means you don't know what style you are in at the point macros are expanded)