What's the best way to vertically center inline text for both math and text modes?
Is there something similar to \textsuperscript for non-math mode?
It's a good occasion for illustrating a macro by Victor Eijkhout, that can be found in TeX by Topic, section 12.6.8; the advantage over directly using \vcenter is that \setbox<number>=\xvcenter{...} is possible.
The \midscript macro chooses a smaller size in (first level) subscripts or superscripts. It won't give good results in second level ones.
\documentclass{article} % macro by V. Eijkhout in TeX by Topic \makeatletter \protected\def\xvcenter{% \hbox\bgroup$\everyvbox{\everyvbox{}\aftergroup\m@th\aftergroup$\aftergroup\egroup}% \vcenter } % The \everyvbox token list will be executed % just after the { that follows \vcenter; % the closing } will trigger the three \aftergroup tokens % so $ will balance the formula started in the outer \hbox % and \egroup will close it. % I added to Eijkhout's macro also \m@th to neutralize the % \mathsurround and \protected, just to be on the safe side. \DeclareRobustCommand{\midscript}[1]{ \mathchoice{\mid@script\scriptstyle{#1}} {\mid@script\scriptstyle{#1}} {\mid@script\scriptscriptstyle{#1}} {\mid@script\scriptscriptstyle{#1}} } \newcommand{\mid@script}[2]{ \vcenter{\hbox{$\m@th#1#2$}} } \DeclareRobustCommand{\textmidscript}[1]{% \xvcenter{\hbox{\scriptsize#1}}% } \makeatletter \begin{document} $x^{a}$ $x_{a}$ $x\midscript{a}-$ $x^{x\midscript{a}-}$ x\textsuperscript{a} x\textsubscript{a} x\textmidscript{a} \end{document} 
\xvcenter{...} in \textmidscript handle anything more robustly than $\vcenter{...}$ does? Maybe something like this? (The trailing unary minus sign at the end of the first row is there just to demonstrate that the "middlescript letter" is aligned on the math-centerline.)

\documentclass{article} \newcommand\mathmiddlescript[1]{\vcenter{\hbox{$\scriptstyle #1$}}} \newcommand\textmiddlescript[1]{$\vcenter{\hbox{\scriptsize #1}}$} \begin{document} $x^{a}$ $x_{a}$ $x\mathmiddlescript{a}-$ x\textsuperscript{a} x\textsubscript{a} x\textmiddlescript{a} \end{document} \def\textvcenter{\hbox \bgroup$\everyvbox{\everyvbox{}\aftergroup$\aftergroup\egroup}\vcenter})? I just wonder why the TeX by Topic author chose to publish the latter. \setbox0=\textvcenter{...} \setbox0 just hides text? So Eijkhout's solution just adds a hiding functionality to 'middletext'?
\vcenter{\hbox{..}}in text mode you have\raisebox{\dimexpr\depth-.5\totalheight+\fontdimen22\textfont2\relax}{..}(this one is from memory, I can't test it right now). Let's hope in the future\vcenteris extended into text-mode so we do not need to play with this kind of things…\textvcenterin TeX by Topic (12.6.8):\def\textvcenter{\hbox \bgroup$\everyvbox{\everyvbox{}\aftergroup$\aftergroup\egroup}\vcenter}\textvcenter{lipsum}? Is this built in, or do I need to define this macro in the preamble? I can't seem to get it working.\textvcenter{\hbox{lipsum}}.