# How to write virtually aligned superscript and subscript [duplicate]

I have this line:

\textbf{Adv}\textsuperscript{downgrade}\textsubscript{$Pi$, DP, X}


But I get this output:

And I want it like this:

Can you help me with simple solutions as much as possible plz.

With \rlap and some \raisebox because of ascenders and descenders in the us/superscript:

\documentclass[12pt]{article}

\begin{document}

\textbf{Adv}\textsubscript{\raisebox{-1pt}{\rlap{$\Pi$, DP, X}}}\textsuperscript{\raisebox{1pt}{downgrade}}

\end{document}


The code given above supposes the user knows which is shortest, of the superscript or the subscript text. The shortest has to to be enterd in the code first, the \rlapped. The following code, based on eqparbox makes it automatic:

\textbf{Adv}\textsuperscript{\raisebox{1pt}{\rlap{\eqmakebox[subp][l]{downgrade}}}}\textsubscript{\raisebox{-1pt}{\eqmakebox[subp][l]{$\Pi$, DP, X}}}

• This won't work if the subscript is wider than the superscript. Which is not a problem in the answer to the question this one is a duplicate of. And the “close as duplicate” vote was given several minutes before you answered. – egreg Jul 11 '16 at 20:26
• @egreg: For the first point, I should have explained it's up to the user, in each case, which of the sub or superscript has to be ‘rlapped’. For the ‘close as duplicate’, I must say I didn't notice. Shall I withdraw my answer? – Bernard Jul 11 '16 at 20:58
• I think that you should at least fix it. If you agree it's a duplicate, vote. – egreg Jul 11 '16 at 21:03
• @egreg: Well, the question is indeed a duplicate, but my solution (which is now automatic, hopefully) does not rely on mathmode… – Bernard Jul 11 '16 at 21:22
• \textsuperscript and \textsubscript do rely on math mode anyway. – egreg Jul 11 '16 at 21:29