# how to write 1st 2nd 3rd … in siunitx

The title says it all ;-)

I would like to be able to something like

\SI[certain-number]{18}{\winner}


or something like that

and get 18'th winner'' in return

I Think I should explain why one would want to do this, so I've added this section to my question.

If one would like to explain either placements or events in time (a different sort of placement i guess) it is nice to have the ordered number together with the unit. here are some examples:

They watched in exitement, as the teacher turned up the current and after passing the 22nd A mark on the dial the circuit began to smoke.''

Or:

In a 22 km run after the 15th km line a lot of runners gave up''

I don't know for sure if these examples works in English, but they do in my native tongue, so i thought it weird that siunitx did not support it.

• See tex.stackexchange.com/a/4119/9517 for a non-siunitx answer. Why do you need siunitx exactly? – T. Verron Feb 9 '18 at 10:53
• As far as this being an siunitx question, this seems to me to be asking whether a unit can be defined which takes the value as an argument. This would seem to be incompatible with the \si macro and I don't really see why siunitx needs to be used to manage spacing, "3rd" isn't a value with units "rd". I suspect the correct answer is simply no, this is neither possible with siunitx, nor something the package should attempt to provide. – Dai Bowen Feb 9 '18 at 11:12
• Is the suffix a unit? I don't think so. – egreg Feb 9 '18 at 12:31
• Off-topic nit pick, but "past the 22nd A" doesn't really make any sense - it would just be "above 22A". An "Amp" is not a fixed milepost, it's a rate (J/s). That phase is sort of like saying "the car increased past the 30th MPH". – Tom Carpenter Feb 9 '18 at 17:08
• @egreg If there's a line every kilometer, it makes sense to talk about the fifteenth of those lines and to abbreviate it as 15th km line. It's the difference between talking about the fifteenth of a series of kilometer lines, versus talking about the line at 15km. The other examples make much less sense, though. – David Richerby Feb 9 '18 at 21:33

(A comment up front: I must confess that I have no idea what "18th A" or "220th V" -- where "A" and "V" stand for ampere and volt, naturally -- is supposed to mean.)

You could achieve your objective by (a) loading both the fmtcount and siunitx packages and (b) defining a dedicated macro as follows:

\newcommand{\ordunit}[2]{\ordinalnum{#1}\,\si{#2}}


Then, in the body of the text, write \ordunit{18}{\ampere} or \ordunit{220}{\volt}.

A full MWE:

\documentclass{article}
\usepackage{fmtcount,siunitx}
\newcommand{\ordunit}[2]{\ordinalnum{#1}\,\si{#2}}
\begin{document}
\ordunit{18}{\ampere}, \ordunit{220}{\volt}, \ordunit{21}{loser}
\end{document}

• Thanks a lot, I've tried to come up with an explanation of why this command might be wanted in my question. – Thorbjørn E. K. Christensen Feb 9 '18 at 13:00

Why not do this with fmtcount? If you need spacing netween the ordinal number and the following ‘unit’, you can define a dedicated command:

\documentclass[english]{article}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{fmtcount}
\newcommand\winner[1]{\ordinalnum{#1}\,winner}

\begin{document}

\ordinalnum{18} winner
\bigskip

\winner{18}

\fmtcountsetoptions{fmtord=level}
\bigskip
\ordinalnum{21} loser

\end{document}


• As I stated in a comment, I'd like siunitx to work, to get support for all the cool units it has by default (and ones i might make). I'll let it sit for a couple of days, and accept your answer if another doesn't show ;-) – Thorbjørn E. K. Christensen Feb 9 '18 at 11:12
• Many compliments for your answer. +1. I hope my English is better than last year. – Sebastiano Feb 9 '18 at 11:49
• @ThorbjørnE.K.Christensen: I'm not sure to understand in which context you want to use units from siunitxbut I've added a command with the same (unbreakable) spacing. – Bernard Feb 9 '18 at 11:59
• Thanks for the help, I've tried to explain why I would want what I want more clearly in my question. Mico's answer was exactly it, so I've acceptet that, but thanks a lot still – Thorbjørn E. K. Christensen Feb 9 '18 at 13:00