5

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

Edit: added use case scenarios

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:

First from Mico's answer:

``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.

thanks for the answers.

  • 6
    See https://tex.stackexchange.com/a/4119/9517 for a non-siunitx answer. Why do you need siunitx exactly? – T. Verron Feb 09 '18 at 10:53
  • Thanks @T.Verron. I need siunitx for correct distance between number and unit XD. Also if my self defined unit is not winner, but something else, it's nice just to have the units there ready for use XD. – Thorbjørn E. K. Christensen Feb 09 '18 at 10:58
  • But i guess I could always just do \nth{18}\si{\winner}, but then I'm just not sure whether I should add a space in between or not ;-) – Thorbjørn E. K. Christensen Feb 09 '18 at 10:59
  • 1
    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 09 '18 at 11:12
  • I think the think I wan't the most is the most is a easy combination of units already existing in siunitx and the 1st, 2nd, ... notation @DaiBowen – Thorbjørn E. K. Christensen Feb 09 '18 at 11:15
  • 1
    Could you give us an example of use of an ordinal number and a unit? – Bernard Feb 09 '18 at 11:52
  • 3
    Is the suffix a unit? I don't think so. – egreg Feb 09 '18 at 12:31
  • 1
    No, even after the explanation, you don't have a use for \SI; around the unit km there should be normal interword space. I don't know in your language, but in English it should be “at the 15 km line” (no ordinal). – egreg Feb 09 '18 at 13:44
  • No I would like the unit to be the unit, and the number (with suffix) to be the number. In danish you can say both the 15 km line and the 15th km line, The meaning is different: the (15 km) line and the (15th) (km) line (is there one 15 km line or 15 single km lines) – Thorbjørn E. K. Christensen Feb 09 '18 at 13:59
  • 3
    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 09 '18 at 17:08
  • 1
    Your examples are very unidiomatic. I can imagine talking about current in discrete amps in certain circumstances but it's highly nonstandard. If you ever did want to talk about the "22nd amp" it would certainly be "amp" not "A". Unless you're trying to achieve some specific effect by writing that way, the smoke happened when the current increased past 22A, not "the 22nd A" or "the 22nd amp". – David Richerby Feb 09 '18 at 21:31
  • 2
    @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 09 '18 at 21:33
  • I have tried to make the examples more true. @TomCarpenter I think I could make it work in danish, but not in english (by changing it in a different direction than what i did) but I have tried to figure out something that I could in english ;-) – Thorbjørn E. K. Christensen Feb 09 '18 at 21:42

2 Answers2

13

(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}
Mico
  • 506,678
10

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}

enter image description here

Bernard
  • 271,350
  • 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 09 '18 at 11:12
  • 1
    Many compliments for your answer. +1. I hope my English is better than last year. – Sebastiano Feb 09 '18 at 11:49
  • 1
    @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 09 '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 09 '18 at 13:00