Tell me more ×
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.

If I want to use abbreviations for second, third and so on in my LaTeX documents, I am currently doing this: 2$^{nd}$ which seems unsatisfactory. Is there a macro I'm missing? I'm sure I could define one myself, and it would be fairly easy. But this looks like something that should already have been covered...

share|improve this question

5 Answers

up vote 113 down vote accepted

You should not use math, when it is normal text. Use \textsuperscript instead: 2\textsuperscript{nd}. You can also define a shortcut for this, e.g.

\newcommand{\ts}{\textsuperscript}

Then you could use 2\ts{nd} in the text.

Edit:
An even nicer solution is to load the package nth with the option super and use the \nth command:

\nth{1}, \nth{2}, \nth{3}, \nth{4}
share|improve this answer
28  
+1 for the nth package – Will Robertson Oct 14 '10 at 11:54
2  
That's what I'm talking about! I don't even have to think about whether it's "th" or "rd". Awesome. – Seamus Oct 14 '10 at 12:43
Is \nth{<number>} guaranteed not to be hyphenated? – mozartstraße Feb 16 at 12:48

I guess the quickest and easiest solution is to simply write "2nd", "3rd", etc.

Superscripts aren't really necessary.

share|improve this answer
28  
But where's the fun in that? Any chump can just write "2nd"... – Seamus Oct 14 '10 at 12:40
6  
Unfortunately, sometimes life is a little bit boring – there are solutions that are both simple and correct. But as a consolation, bear in mind that most MS Word users will produce 2-superscript-nd accidentally, and they have no idea how to disable it. – Jukka Suomela Oct 14 '10 at 12:49
8  
Bringhurst (I think) does recommend against using superscript ordinals. But it's nice to be able to \nth things automatically, especially in math mode. – Will Robertson Oct 17 '10 at 3:30
3  
This is the correct answer! Remember that English is not French and does not put st, nd, th into superscripts! – tohecz Oct 24 '12 at 11:48
1  
I read somewhere that the superscript ordinals were usually used by British in the 19th century. I see still here and there. May be this was a foreign influence, but why this changed in the 20th century? To adapt to the preferences of The Chicago Manual of Style or simply because many documents were created with typewriters where it was easier put inline ordinals?. In Spanish there are an undisputed reference for this kind of conventions (the Real Academia Española) but what about English? – Fran Jan 11 at 10:58

An alternative to nth package is fmtcount.

In this case the command is \ordinalnum. By default the ordinal is formatted as superscript, but this is optional, as it is also in nth:

\usepackage{fmtcount} % equivalent to \usepackage[super]{nth}
\usepackage[level]{fmtcount} % equivalent to \usepackage{nth}

But there are some advantages over nth:

  1. Limited multilingual support (English, French, Spanish, Portuguese, German and Italian). For example, in a Spanish document \nth{3} is formatted incorrectly as "3th" but \ordinalnum{3} is rendered correctly as "3º".

  2. Optional gender. For example \ordinalnum{3}[f] produces in Spanish the feminine ordinal "3ª" (tercera). There is also a neuter option (n). By default the gender is m (masculine).

  3. Is if possible switch between raise and level versions of ordinals in the same document (I can't imagine why, but who know!) with \fmtcountsetoptions{fmtord=raise} or \fmtcountsetoptions{fmtord=level}

  4. For English-only users, obviously (1) and (2) features are useless, but the ftmcount package has also many other ordinal commands, as \ordinal{counter} or \ordinalstring{counter} to print a counter as section as an ordinal ("3th") or as textual ordinal ("third") and more.

A third package, engord, also print numbers (\engordnumber{12}), counters (\engord{page}) and can switch between styles with \engordraisetrue or \engordraisefalse, but there are not multilingual or gender support.

On the other hand, for enumerated lists you can use the moreenum package with the labels \raisenth or \levelnth. A MWE:

\documentclass{article}
\usepackage{moreenum}
\begin{document}
\begin{enumerate}[label=\raisenth* --- ,start=1]
\item one
\item two
\item three
\end{enumerate}
\end{document}
share|improve this answer
The moreenum package actually just uses fmtcount at bottom. (I wrote the package: it's nice to see that a question I asked prompted my to write a package which then became an answer to that question.) – Seamus Jan 10 at 11:14
@Seamus, I knew from the moreenum that load fmtcount and even that the author read this site (egreg quote) but I did not realize that your username is the name of the author! Is the danger of answer in this site: May be you're trying to give a lesson to the teacher! X-D – Fran Jan 10 at 14:40

If you are using ConTeXt MkIV, you can even imitate the automatic conversion of MS Word:

\usemodule[translate]
\translateinput[2nd][2\high{nd}]
\enableinputtranslation

\starttext
On the 2nd of November \unknown
\stoptext

This will translate all 2nd into 2\high{nd}.

share|improve this answer
1  
Neat. How does this \translateinput work? It looks like XeTeX's input mapping but it must occur earlier in the processing. – Will Robertson Oct 17 '10 at 3:28
I am not 100% sure on how it works. The translate module just registers a "user" filter. Looking at the source, this is how I understand what is happening. The input file is read line by line and first the input translation (encoding regimes and such) is done, then unicode translation (collapsing characters, etc) is done, and finally user translations are done. All this is done in the openers.textopen function in data-tex.lua file. – Aditya Oct 17 '10 at 7:38
Is it possible to implement \translateinput in LaTeX as well? Might come in handy. – marczellm Jan 10 at 10:11
@marczellm: Since \translateinput is based on luatex, it is possible to implement it in LuaLaTeX. But I don't know how easy it will be to translate the ConTeXt code to LaTeX. – Aditya Jan 10 at 20:24

If you're after speed when writing, this solution seems to be the quickest to type

\documentclass{article}
\usepackage{xspace}

\newcommand\nd{\textsuperscript{nd}\xspace}
\newcommand\rd{\textsuperscript{rd}\xspace}
\newcommand\nth{\textsuperscript{th}\xspace} %\th is taken already
\begin{document}
This is the 2\nd of December. Or the 4\nth of July. Or 3\rd place in a race.
\end{document}

The \xspace command intelligently decides whether there should be a space after the macro or not.

MWE

share|improve this answer
2  
For maintain the space when appropriate you can use the package xspace. There are several questions about this package in the corresponding tag. – Fran Jan 10 at 23:06
Thanks! Edited my answer to include xspace. – Nathanael Farley Jan 11 at 8:51

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.