How to correctly write number ranges?

Suppose I would like to write something like: "She has between 1-5 cookies on her at all times."; what is correct way to write such a number range in TeX?

Is it:

$1$-$5$


Or:

$1\text{-}5$


Or something else entirely? To me, both of the above seem clumsy.

-
1--5 is OK for me. –  Sigur Jul 30 at 23:07
This depends on specific language rules. In German, for example, it is usual to write the numbers as their words, i.e. one to four (eins bis vier), but from 5, the figure is used. I would not tag this question as hyphenation ... –  Christian Hupfer Jul 30 at 23:14
Using "between" in connection with a range sounds weird to me to start with really. I'd say "between 1 and 5" "she has 1 - 5 cookies" (with a strong preference for the former) –  Clément Jul 31 at 7:27
@Christian Swiss German? Because in Austrian/German German the rule I learned was 0-12 written out (as well as "round numbers" such as one hundred). Although the duden says that's antiquated.. oh well. Anyhow to make this less off-topic: Independent which method you use when writing number ranges, you should in any case use the en-dash -- and not the hyphen -! –  Voo Jul 31 at 11:34
@Voo? Did I say Swiss German? No. –  Christian Hupfer Jul 31 at 13:03

Why not go the SI way ;)

\documentclass{article}
\usepackage[detect-all]{siunitx}
\begin{document}
This is a range from  \numrange{1}{10}.
This is a range from  \numrange[range-phrase = --]{1}{10}.
\end{document}


Here is some more.

\documentclass{article}
\usepackage[detect-none]{siunitx}
\sisetup{range-phrase = \text{--}}
\begin{document}
This is a range from  \numrange{1}{10}.

This is a range from  $\numrange{1}{10}$.

This is a range from  $\SIrange{1}{10}{}$.
\end{document}


-
+1, plus it can be used in math and in text mode. –  BMWurm Jul 30 at 23:38
I don't really see how you could mention such a kind of range number in math mode (except with $\text{...}$ of course), nor the use of using siunitx if you define the separator locally. –  anderstood Jul 30 at 23:50
@anderstood I just meant that you could use {\numrange} in text mode and in math mode, IF you have a scenario where that would be necessary, of course. {\SIrange} is of course more likely to turn up in math mode, if you are using temperature ranges for instance. It obviously depends on your document, but chances are, you can use SI elsewhere in your document, so IF the package is already included, why not use it. And of course you need not define the seperator locally. –  BMWurm Jul 31 at 0:02
Does that switch to maths mode in the middle of text, though? That seems to me wrong unless the numbers are really mathematics. But maybe that is not what this does - or not the first case, anyway. –  cfr Jul 31 at 0:17
@cfr That one is possibly for Joseph Wright! :) –  Harish Kumar Jul 31 at 0:18

Why use math mode? I would do as suggested here and write

She has 1 to 5 cookies on her at all times.
(She has between 1 and 5 cookies on her at all times.)


From wikipedia (Dash article):

Various style guides (including the Guide for the Use of the International System of Units (SI) and the AMA Manual of Style) recommend that when a number range might be misconstrued as subtraction, the word "to" should be used instead of an en dash. For example, "a voltage of 50 V to 100 V" is preferable to using "a voltage of 50–100 V". Relatedly, in ranges that include negative numbers, "to" is used to avoid ambiguity or awkwardness (for example, "temperatures ranged from −18°C to −34°C"). It is also considered poor style (best avoided) to use the en dash in place of the words to or and in phrases that follow the forms from … to … and between … and ….[13][14]

-
The grammar doesn't seem to make sense to me :/ Wouldn't you write "She has 1-5 cookies" or "between 1 and 5"? "Between 1 to 5" sounds weird. –  Clément Jul 31 at 7:25
@Clément: Indeed -> "She has 1 to 5 cookies", OR "She has between 1 and 5 cookies"... As you guessed I used the initial example. Does not make any difference to my answer. –  anderstood Jul 31 at 13:26

In LaTex, the hyphen used for ranges like pages of a book, etc. is referred to as an en-dash and is best written as:

She has between 1--5 cookies on her at all times.

It is also possible to use the math mode as follows but the first approach is preferable:

She has between $1$--$5$ cookies on her at all times.

Or:

She has between $1\textup{--}5$ cookies on her at all times.

For nontechnical writing, though, the best approach is to use to to avoid any ambiguity.

The result of the above three approaches is as follows (and are identical):

-
If you use another font for normal text and math mode for the numbers you'll have a strange format. –  Sigur Jul 30 at 23:33
@Sigur-- That is why I mention it second. But in some cases, especially in technical documents where large number of equations and numbers is used, it is preferable to use the same style in math and text modes for consistency. For example, we should write the term $2 x$ in equation... and not the term 2 $x$ in equation... –  AboAmmar Jul 30 at 23:51
If you have to convert your document to Word at some point, it creates needless complications. (All the maths becomes images and you have to go through and remove them all.) –  cfr Jul 31 at 0:19

Neither option is correct, for several reasons.

3. Most style guides recommend using an en-dash (-- in (La)TeX) for number ranges, not a hyphen (-).