Math & ScienceNorwegian comma vs period for decimal numbers.

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Xiphias
Posts: 12
Joined: Thu Aug 13, 2015 9:02 am

Norwegian comma vs period for decimal numbers.

Post by Xiphias »

Most of the world will write a decimal number like this: "0.36704 or .36704" and write a large number like this: "3,000,000"

In Norway (and probably other places in Europe), however, we write a decimal number like this: "0,36704 (and never ,36704)" and a large number like this: "3 000 000"

If I use comma "," in math environment in latex, I get a small space to the right of it as a result of it mostly being used for coordinates. Is there a way to set it up in such a way that this space is removed by default?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Norwegian comma vs period for decimal numbers.

Post by Stefan Kottwitz »

You could use the icomma package. It makes the comma context aware: if there's a space after the comma, it works like before with a small space after it, if there's not space then it works like a decimal separator without additional spacing after it. So it works like expected, still letting you the option for having space.

Code: Select all

\documentclass{article}
\usepackage{icomma}
\begin{document}
$(x, y) = (0, 3)$ % with desired space
and $z = 0,36704$.% no space after decimal separator
\end{document}
comma.png
comma.png (9 KiB) Viewed 12341 times
Stefan
LaTeX.org admin
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Norwegian comma vs period for decimal numbers.

Post by cgnieder »

Without a package wrap the comma in braces:

Code: Select all

\documentclass{article}
\begin{document}

$(x,y)$ $0{,}1234$ $3\,000\,000$

\end{document}
The package siunitx and its \num macro allows for very much customization of the printing of numbers. Here's a very short example:

Code: Select all

\documentclass{article}
\usepackage{siunitx}
\sisetup{
  add-decimal-zero = true , % default setting, not needed
  output-decimal-marker = {,} ,
  group-separator = \, % default setting, not needed
}
\begin{document}

\num{0,1234} \num{.1234} \num{3000000}

\num{2.} \num{3}

\end{document}
Regards
site moderator & package author
Xiphias
Posts: 12
Joined: Thu Aug 13, 2015 9:02 am

Re: Norwegian comma vs period for decimal numbers.

Post by Xiphias »

icomma package is a thing of beauty. thanks! :)
Post Reply