TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to use sub- and superscript together in text mode. I've found this macro to solve the problem


But it doesn't works well when the subscript is long. In that case the subscript overlaps with the following character.

What could be the macro to enable sub- and superscripting in all cases?

share|improve this question
Check out the comment to this answer: tex.stackexchange.com/questions/1013/… – Andrey Vihrov Jul 25 '11 at 12:10
up vote 7 down vote accepted

We need to have enough space for the longest of the two sub-/superscripts. For that we can calculate the maximum of both sub-/superscripts' widths and make a box as wide as the maximum:


\usepackage{fixltx2e} % For \textsubscript






The result

I refrained from using mathmode and \text because \textsuperscript and \textsubscript may have more complex implementations than it would seem (see realscripts, for example).

share|improve this answer
Thanks for the answer. Can I ask, why there is a need to put a comment character in the end of each line? – jutky Jul 26 '11 at 18:53
@jutky: tex.stackexchange.com/questions/7453/… – Andrey Vihrov Jul 26 '11 at 23:07

It's just the same code as for \textsuperscript in the LaTeX kernel with subscripts added.

The result is the same as Andrey's.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.