Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

What is the easiest way to superscript text outside of math mode?

For example, let's say I want to write the $n^{th}$ element, but without the math mode's automatic italicization of the th. And what if I still want the n to be in math mode, but the th outside?

share|improve this question
9  
See this column in TUGboat for information about not using a superscript "th" –  egreg Mar 8 '12 at 22:41
3  
@egreg Interesting! –  Nico May 14 '13 at 15:17
1  
@egreg TL;DR Why should I avoid using the ansber by Werner? –  Bernhard Sep 19 '13 at 14:14
2  
@Bernhard Too long? It's one column! … the use of the superscript form seemed to have disappeared around the 1940s and 50s — until its corpse was reanimated by Microsoft. Perhaps it had been lingering, zombie-like, in rural and provincial corners of Britain, North America, and elsewhere in the English-speaking world. –  egreg Sep 19 '13 at 14:49
2  
@Bernhard My summary is: it is an abbreviation style unique to English, people stopped using it because of the spread of typewriters where it looked bad and was cumbersome to produce and then Microsoft decided to bring it back. Thus we shouldn't use it. It seemed like a non-sequitur to me. –  Eponymous Apr 14 at 17:20

3 Answers 3

up vote 106 down vote accepted
+200

You can use \textsuperscript{th}. It sets its contents in text mode and can be used in math or text mode.

share|improve this answer
    
Actually, this only really works outside math mode. If I try $n^\textsuperscript{th}$, the superscript gets raised too high, creating an awkwardly large space between lines. But $n$\textsuperscript{th} works great--thanks! –  jamaicanworm Mar 9 '12 at 0:49
12  
@jamaicanworm: You should use $n\textsuperscript{th}$. –  Werner Mar 9 '12 at 0:50
8  
$n^\textsuperscript{th}$ is a double superscript. –  Philipp Mar 9 '12 at 0:51
2  
Right! Silly mistake... :) –  jamaicanworm Mar 9 '12 at 0:52
    
@Werner: What is the difference between $n$\textsuperscript{th} and $n\textsuperscript{th}$? Is it the spacing at the end of the inline math environment or why, if else, do you prefer the second one? –  strpeter Apr 30 at 8:44

For 99% of applications, Werner's answer is good enough. But since Marienplatz has offered a bounty, there presumably is interest in other ways to do this. So here, I show it done with a stack over a null entry. My preamble definition (output on the second line) appears to give the exact same result as \textsuperscript (output on the first line).

But then, I show how both the size of the script as well as the height of it can be simply changed with my stacking approach, shown in \footnotesize (and lowered) in the 3rd line of output, and in \tiny (and raised) in the last line.

While I stick just to the standard text font sizes, it would be trivial to instead use a \scalebox to get exactly the size of script text desired.

If there is a desire to place the script, not at a fixed elevation, but relative to the height of the character being scripted, that is easy too (just ask).

\documentclass{article}
\usepackage{stackengine}[2013-10-15]
\newcommand\textss[1]{\stackengine{.9ex}{}{\scriptsize#1}{O}{l}{F}{F}{L}}
\begin{document}
\noindent
a\textsuperscript{th}A\textsuperscript{th}\\
a\textss{th}A\textss{th}\\
\renewcommand\textss[1]{\stackengine{.7ex}{}{\footnotesize#1}{O}{l}{F}{F}{L}}
a\textss{th}A\textss{th}\\
\renewcommand\textss[1]{\stackengine{1ex}{}{\tiny#1}{O}{l}{F}{F}{L}}
a\textss{th}A\textss{th}\\
\end{document}

enter image description here

share|improve this answer
1  
I am very very sorry for disappointing you. The bounty target has been set in advance. It is for Werner's answer. :-) Anyway, +1 for your solution. –  In PSTricks we trust Oct 26 '13 at 6:53
1  
@Marienplatz Oops. No problem. Thanks for the consideration. –  Steven B. Segletes Oct 26 '13 at 12:32

In ConTeXt, you can use

\high{th}

to get the superscripts in text mode.

share|improve this answer

Your Answer

 
discard

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.