MWE:
\documentclass{scrbook}
\begin{document}
\makeatletter
\show\@textsuperscript
\show\sf@size
\makeatother
A\textsuperscript {B}C
A{\selectfont{${^{\mbox{\fontsize\sf@size\z@ B}}}$}}C
\end{document}
The log shows:
#1->{\m@th \ensuremath {^{\mbox {\fontsize \sf@size \z@ #1}}}}.
l.6 \show\@textsuperscript
> \sf@size=undefined.
l.7 \show\sf@size
How would I perform the \textsuperscript macro in the raw, without invoking the macro? Trying to learn some TeX!
UPDATE: Thanks to answer from Kruger, this works as expected.
Now, the question is why the raw invocation shows a bigger font size for the superscript compared to \textsuperscript?
UPDATE: Thanks to answer from Kruger, all complete!
It's been a fascinating rabbit hole!
Final answer: \ensuremath sets sf@size. Details in accepted answer.
A\textsuperscript {B}C
\makeatletter
A$\ensuremath{^{\mbox{\fontsize\sf@size\z@ {\selectfont B}}}}$C
\makeatother
A$^{\mbox{\fontsize\sf@size\z@\selectfont B}}$C. And no,\ensuremathdoes not set\sf@sizeas part of its job; it's a side effect of doing a math formula. – egreg Apr 25 '18 at 07:53