4
\documentclass{book}
\usepackage{nth}
\begin{document}
\nth{3} is not the same as $\nth{3}$
\end{document}

This code works fine for numbers.Now , In the argument if I want to pass III , what should I do?

I want the output as III(in slanting--> I achieved this using Math Mode)rd(in super script)

6
  • Could you clarify your question? I'm having trouble understanding the problem. As I understand it, you want a text command which will produce the equivalent of $\nth{3}$. Is that right? Where does superscript come in? On second thoughts, where do roman numerals come in? Why would you want e.g. 'IIIrd', if that is what you want?
    – cfr
    Jan 20 '14 at 1:55
  • 3
    I might be wrong, but I don't think it's standard practice in English to write something like ii^{nd}, iii^{rd}, iv^{th}, etc. While I believe I may have seen this sort of thing in other languages, I cannot ever recall seeing it in English. For example, we write King Henry VII, and though we say King Henry the seventh, we don't write VII^{th}.
    – A.Ellett
    Jan 20 '14 at 1:59
  • 1
    There is \textsuperscript{...} available outside of a math environment.
    – A.Ellett
    Jan 20 '14 at 2:01
  • By the way, your code doesn't give me superscript at all right now. Is that expected?
    – cfr
    Jan 20 '14 at 2:01
  • 2
    Writing III^{rd} is simply wrong. Don't do it.
    – user11232
    Jan 20 '14 at 2:35
9

If I understand your question correctly, then (as has been suggested in comments to the question) I think it is not a standard practice in English to write something like III^{rd}, let alone using italicized font, and I would suggest you not to use this.

That being said, one way to achieve what you want is to define a command similar to \nth, but converting the argument to (upper case) Roman numerals. Three options: one, using roman font for the complete expression; another one using slanted font for the numeral and roman font for the superscript, and the third one, using slanted font for the complete expression:

\documentclass{book}
\usepackage[super]{nth}

\def\Rnth#1{{% First print number:
  \expandafter\nthM \MakeUppercase{\romannumeral\number#1}\relax
  \nthscript{%
  \ifnum#1\nthtest0 th\else % negatives are all ``th'' (depending on \nthtest)
  \expandafter \nthSuff \expandafter 0\number\ifnum #1<0-\fi#1\delimiter
  \fi
 }}}
\def\RSnth#1{{% First print number:
  \expandafter\nthM \slshape\MakeUppercase{\romannumeral\number#1}\kern1pt\relax
  \nthscript{%
  \ifnum#1\nthtest0 th\else % negatives are all ``th'' (depending on \nthtest)
  \expandafter \nthSuff \expandafter 0\number\ifnum #1<0-\fi#1\delimiter
  \fi
 }}}
\def\Rsnth#1{{% First print number:
  \expandafter\nthM \slshape\MakeUppercase{\romannumeral\number#1}\kern-1pt\relax}
  \nthscript{%
  \ifnum#1\nthtest0 th\else % negatives are all ``th'' (depending on \nthtest)
  \expandafter \nthSuff \expandafter 0\number\ifnum #1<0-\fi#1\delimiter
  \fi
 }}

\begin{document}

\Rnth{3} is not the same as \nth{3}.

\Rnth{2} is not the same as \nth{2}.

\RSnth{3} is not the same as \nth{3}.

\RSnth{2} is not the same as \nth{2}.

\Rsnth{3} is not the same as \nth{3}.

\Rsnth{2} is not the same as \nth{2}.

\end{document}

enter image description here

If you want the numeral to be in italics shape, replace \slshape with \itshape in the corresponding definition(s).

In my opinion, the two options using slanted font look really ugly; please consider not using those.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.