28

I would like to show both super and subscript together some text.

I tried this sometext\textsuperscript{1}\textsubscript{2}

But 2 does not show up right below 1.

Thanks for your help. Also how can I show 1 & 2 in front of sometext as well.

regards Aku

I tried some both the answers posted below and here is the attachment. I was trying to put 2 digit number 16 and 32 in superscript and subscript. alt text

alt text

2
  • 1
    then you didn't put it into braces: ^{16}_{32}. That was the behaviour Alan already pointed out.
    – user2478
    Commented Jan 4, 2011 at 19:51
  • This is also an argument in favour of never leaving the braces off after ^ and _ in answering these types of questions. :-)
    – Alan Munn
    Commented Jan 4, 2011 at 21:38

4 Answers 4

22

without using directly math and with colors:

\documentclass{article}
\usepackage{fixltx2e}
\usepackage{xcolor}
\def\SPSB#1#2{\rlap{\textsuperscript{\textcolor{red}{#1}}}\SB{#2}}
\def\SP#1{\textsuperscript{\textcolor{red}{#1}}}
\def\SB#1{\textsubscript{\textcolor{blue}{#1}}}

\begin{document}
\huge
sometext\SPSB{1}{2} more text

sometext\SP{1} more\SB{2} text\SP{1}

\end{document}

alt text

4
  • Why it is reducing the text size of "sometex" & "more text" to scriptsize. It should be in the normal size and only sub-superscript should reduce in size
    – Aku
    Commented Jan 4, 2011 at 20:31
  • @Aku: I cannot see it. Give an example.
    – user2478
    Commented Jan 4, 2011 at 20:41
  • sorry, it was the document view, because of which I thought it coming as scriptsize. It works just fine
    – Aku
    Commented Jan 4, 2011 at 22:53
  • 4
    The coloring unnecessarily complicates this answer. \rlap is all you need.
    – E...
    Commented Aug 3, 2020 at 16:06
13

use it in math mode, digits are always set in upright mode.

\documentclass{article}
\usepackage{fixltx2e}
\begin{document}
\Huge
sometext\textsuperscript{1}\textsubscript{2}

sometext$^1_2$ \qquad$^1_2$sometext

\end{document}
0
10

Math mode:

sometext$^1_2$

or (with amsmath):

$\text{sometext}^1_2$
2
  • 2
    Remember that if you need non-numeric sub- and superscripts, you'll need to enclose them in text{} (from amsmath). e.g. sometext$^{\text{super}}_{\text{sub}}$ otherwise the text won't come out correctly.
    – Alan Munn
    Commented Jan 4, 2011 at 17:51
  • That's right. But it's not clear whether sometext\textsuperscript{1}\textsubscript{2} should be in text mode. Afterall, numbers are always typeset in the same typeface by default.
    – Leo Liu
    Commented Jan 6, 2011 at 4:59
3

To typeset "sometext" followed by "'1' above '2'" you can simply use:

sometext\rlap{\textsuperscript{1}}\textsubscript{2}

This will only work nicely if the superscript is longer than or equal to the subscript in width. If the subscript is longer, place it first and inside the rlap.

1
  • Is this, maybe, back-to-front? I'm finding the shorter needs to be placed in the rlap.
    – Ian
    Commented Nov 14, 2022 at 9:32

You must log in to answer this question.

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