[OS X TeX] Superscripts for ordinals

Maarten Sneep maarten.sneep at xs4all.nl
Mon Feb 28 21:15:18 CET 2005

On 28 feb 2005, at 20:47, Doug Fields wrote:

> Is there a way to get a standard "superscript" in LaTeX easily?

\textsuperscript{} is for use in text. It matches the surrounding text  
(sans serif, roman or italic, ...)

> \ord{} which checks the previous character and gives the appropriate  
> superscript ordinal extension (for English, anyway; I'm sure others  
> can add the iemes and whatever they want). Possibly \ord{21} which  
> does the same thing but takes the information in there.

There is an 'ordinal.sty' on CTAN, which sorts out the correct  
characters, although the number is written out until 19 (20th is used  
for higher numbers). You'll have to add the superscripts yourself. I  
noticed it is no longer on CTAN, only on an old mirror, I've included  
the source below (though you could Google for this yourself).

> Eventually I'll receive some of these books (already ordered) and I'm  
> sure will learn how to do simple things like these, but until then...

The \textsuperscript is indeed trivial, but the \ord{} isn't.


% ordinal.sty
% ===========
%    Keith M Swartz <solo26 at mit.edu>
%      with helpful corrections from Donald Arseneau  
<asnd at erich.triumf.ca>
%    Wed May 26 1993  14:24:35 1993
% Creates a macro that returns the ORDINAL value of a counter.  Returns
% text for numbers up to and including 19, and displays number with  
% from 20 and on.  For example:
%   \nth{2}   ==> second
%   \nth{15}  ==> fifteenth
%   \nth{31}  ==> 31st
%   \nth{112} ==> 112th
% See the file ordinal-test.tex for an example of its use.

\def\nth#1{\ifcase#10th~\or first~\or second~\or third~\or fourth~\or%
   fifth~\or sixth~\or seventh~\or eighth~\or ninth~\or tenth~\or%
   eleventh~\or twelfth~\or thirteenth~\or fourteenth~\or fifteenth~\or%
   sixteenth~\or seventeenth~\or eighteenth~\or nineteenth~\else%

   \@tempcnta=#1  \number#1\@ %
   \ifnum\@tempcnta<\z@ \@tempcnta\z@\fi % negatives all get th
   \@tempcntb\@tempcnta \divide\@tempcntb100 % hundreds
   \multiply\@tempcntb100 \advance\@tempcnta-\@tempcntb % n mod 100
   \ifnum\@tempcnta<20 \ifnum\@tempcnta>9 th~\fi % teens get th
     \else \@tempcntb\@tempcnta \divide\@tempcntb10 % tens
     \multiply\@tempcntb10 \advance\@tempcnta-\@tempcntb % n mod 10
     \ifcase\@tempcnta th~\or st~\or nd~\or rd~\else th~\fi \fi}

--------------------- Info ---------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
           & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>

More information about the macostex-archives mailing list