43

I'm using siunitx to input some big numbers and units in my document.

Is there a way to make the output of \num{3.14} be "3,13" instead of "3.13"? In Spanish, we use the first one.

lockstep
  • 250,273
Tomas
  • 5,441
  • 2
    Related: http://tex.stackexchange.com/questions/18673 http://tex.stackexchange.com/questions/13949 – Andrey Vihrov Jun 16 '11 at 05:32
  • 2
    @Andrey: A tip: If you copy and paste the entire URL of a tex.sx question in your comment, it'll automatically get shortened and display the question when you mouseover the link, e.g. http:// tex.stackexchange .com /questions/18673/german-language-use-of-comma-in-numbers (w/o spaces) becomes http://tex.stackexchange.com/questions/18673/german-language-use-of-comma-in-numbers – doncherry Jun 16 '11 at 08:07
  • 3
    @Tomas: Wait ... did you actually want to get 3,1_3_ when you input 3.1_4_? – doncherry Jun 16 '11 at 08:48
  • 5
    @Tomas: the ISO norm 80000-1, accepts both the period and the comma as decimal separator, and in the most recent version of the Ortografía de la lengua española, our Academia recommends the use of the period as decimal separator, although the comma is still accepted. More information here: La marca decimal – Gonzalo Medina Jun 16 '11 at 12:55
  • @Gonzalo: Thanks for the info, i did't know the period is allowed as well. The problem is that using \usepackage[spanish]{babel} all the number inputs with decimal in math mode get a , regardless the code being . or ,. So, I'd have to change an option of the label package to make it display periods. Do you know how to do that? – Tomas Jun 16 '11 at 16:39
  • @Tomas: After loading \usepackage[spanish]{babel} you can use \decimalpoint to use the point as decimal separator, and \decimalcomma to revert to the comma. – Gonzalo Medina Jun 16 '11 at 16:53
  • @Gonzalo: In siunitx I tend to aim for consistency with current publishing practice. What is the situation 'on the ground' at the moment: . or ,? – Joseph Wright Jun 16 '11 at 16:56
  • 3
    @Tomas: \usepackage[spanish,es-nodecimaldot]{babel} should be enough. – egreg Jun 16 '11 at 16:56
  • So the recommendation would be . for the decimal marker and \cdot for exponents. I guess that means \, as the digit-grouping separator. What about between units (\, and \cdot seem to be the common choices)? – Joseph Wright Jun 16 '11 at 17:02
  • @Joseph: as I said before, both are accepted by the international norm I mentioned, and recently the Real Academia Española recommended using the period instead of the comma, although the latter is still accepted. – Gonzalo Medina Jun 16 '11 at 17:14
  • @Joseph: I don't have any problem using . instead of , for decimal since everyone would understand it anyway. This should be something universal and i think it's better to use @egreg solution and leave siunitx with default settings. – Tomas Jun 16 '11 at 17:15
  • @Joseph: between units, the fine space is to be used, and never a dot, although in practice, most people tend to use the dot. The norm, however, dictates a fine space to separate the groups of three digits: as in 3,123,456 – Gonzalo Medina Jun 16 '11 at 17:18
  • @Joseph: of couse, all my remarks are only valid for Spanish. – Gonzalo Medina Jun 16 '11 at 17:20
  • @Gonzalo: Is that the same space i should use for separate the number from the unit? As in: \num{85+30i}\;\si\ohm? – Tomas Jun 16 '11 at 17:21

1 Answers1

54

At the most basic

\sisetup{output-decimal-marker = {,}}

will do the job.

The package includes some pre-defined 'locales' for different typographic traditions, for example

\sisetup{locale = FR}

To date, I've not had details on Spanish conventions, so do not have an ES locale (there is more than just the decimal marker to worry about). In particular, what do you use for the exponent, 1.23 \times 10^{3} or 1.23 \cdot 10^{3} (or ...).

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
  • 2
    Thanks. We use \cdot for exponents. \times is more used for operations like vector products. Oh, i almost forgot. We use period for thousand separation. – Tomas Jun 16 '11 at 16:43
  • @Thomas: How do you write a 3D point (spherical coordinate system), for example, (21.3,30.5,10) in Spanish? – kiss my armpit May 14 '12 at 08:33
  • 1
    @Joseph I think a single locale for Spanish is not possible. Very likely we need ES_es, ES_mx, ES_ar, and so on. – Javier Bezos Oct 17 '12 at 14:00
  • 2
    @JavierBezos No, that would be confusing locale and language. ES would be Spain, I guess MX is Mexico, and so on. (For example, FR does not mean the text is in French, it means that the typography follows the conventions in use in France.) – Joseph Wright Oct 17 '12 at 15:42
  • 2
    You can also load the package with this option: \usepackage[locale=FR]{siunitx} – Martin Thoma Jan 13 '14 at 10:55
  • Hi, how can I write a custom locale, inside the document? – Minh Nghĩa Sep 10 '20 at 11:51
  • @JosephWright This forces both $\num{3.14}$ and $\num{3,14}$ to show up as 3,14. Is it possible to use both . and , as decimal separators and display the input faithfully? That is, $\num{3.14}$ gives 3.14, and $\num{3,14}$ gives 3,14. If it is, how? (May I suggest adding this information to the answer here to avoid a new question? :) ) – Linear Christmas May 20 '21 at 18:07
  • This solution does not seem to work with R input. If the input comes from R then siunitx results with the error message like ! Package siunitx Error: Invalid number '\protect \text {0,001}'. and if the input is direct then siunitx works just fine. Why is that? – user7351278 Dec 27 '22 at 17:51