I want to use super and subscript at the same time in text mode. I cannot use math mode because I created macros which only work in text mode.

I found this question: Vertically aligning textsuperscript and textsubscript together

But the suggested answer does not work because the width of the resulting text is based only on the subscript, if the superscript is longer the text overlaps with the content afterwards.

I created the following versions for longer sub / superscripts but i need them combined:




prefix\SPSBbottom{long}{1}text \\[1cm]
prefix\SPSBbottom{1}{long}text \\[1cm] % Working combination
prefix\SPSBtop{long}{1}text \\[1cm] % Working combination
prefix\SPSBtop{1}{long}text \\[1cm]


If I could place two text at the same place and the width is taken from the longer one than using \textsuperscript{#1 'and' \phantom{#2}}\textsubscript{#2 'and' \phantom{#2}} could work but I do not know how to do this.

Alternatively one could use the math form $A^{top}_{bottom}$ where top and bottom are in a nested normal mode (\text{} does not work). But I found no way to do this as well.

Thanks in advance :-)

  • 1
    Welcome to TeX - LaTeX! What do you mean with »\text{} does not work«? $A^{\text{top}}_{\text{bottom}}$ works fine (if the amstext or amsmath package has been loaded)
    – cgnieder
    Commented Sep 14, 2015 at 17:35
  • I was really sure it did not work because of nested math modes and stuff. However it seems that I changed my macros over time in such a way that it does work now :-). Thanks
    – Manuel
    Commented Sep 15, 2015 at 17:10

2 Answers 2


Duplicate the definition of \textsuperscript:






Add \strut to the second argument if you prefer.

enter image description here


The stackengine package provides this feature directly, in the form of \stackanchor. If the stacking type is Short, the gap between the sub and superscript is set to a specified length. This mimics, in form, the natural behavior of the sub and superscripts in math mode. In the case of short stacks, the gap is centered about the math axis.

On the other hand, if the application requires sub and superscripts to be set at fixed vertical locations, regardless of the natural height of sub and superscript, then one can set the stacking type to Long, which uses a specified baselineskip between the sub and superscript. In the case of long stacks, the baselines of the sub and superscripts are symmetric about the baseline of the text

\setstackgap{S}{2pt}% SHORT STACK DEFAULT GAP
\setstackgap{L}{.7\baselineskip}% LONG STACK DEFAULT BASELINESKIP
\def\stackalignment{l}% LEFT STACKING ALIGNMENT


enter image description here

For completeness, if one did want the stacks to be set in math mode, one can either declare \stackMath (a global declaration), or use \ensurestackMath{} on the \stackanchor.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .