[texhax] Superscript ordinal indicators in dates?

Joel C. Salomon joelcsalomon at gmail.com
Fri Jun 5 18:25:00 CEST 2009


2009/6/4 E. Krishnan <ekmath at asianetindia.com>:
> On Thu, 4 Jun 2009, Joel C. Salomon wrote:
>> How can I get the date in my LaTeX article to display the ordinal
>> indicator in superscript?  E.g., July 4<sup>th</sup>, 1776
>
> Please try
>
>  \def\mydate{\ifcase\day\or
>   1$^{\hbox{st}}$\or 2$^{\hbox{nd}}$\or 3$^{\hbox{rd}}$\or
<snip>
>   31$^{\hbox{st}}$\fi~\ifcase\month\or
>   January\or February\or March\or April\or May\or June\or
>   July\or August\or September\or October\or November\or
>   December\fi,\space \number\year}

I moved the \ifcase\month to the front and replaced the $^{hbox{—}}$
with \textsuperscript{—}, then added
	\date{\mydate}
—that works OK.

So I followed Uwe & Donald's advice, and kept an eye out for how the
packages format the raised ordinals. Since the nth package uses
\textsuperscript rather than playing math games, I thought to say:
	\usepackage[super]{nth}
	\def\mydate{\ifcase\month\or
		January\or February\or March\or April\or May\or June\or July\or August\or
		September\or October\or November\or December\fi~\nth{day},\space
\number\year}
	\date{\mydate}
But that’s not working—I get a "missing number" from \maketitle.  What
am I doing wrong?

Also, I’d like to hook in into LaTeX date formatting so that the
\today command will be formatted as I’d prefer.

—Joel


More information about the texhax mailing list