# A comma decimal separator that is bigger than a dot

\documentclass{mwrep}
\usepackage{amsmath}
\begin{document}
Check:\\
with "," $0,125$\\
with "." $0.125$

with commas:
$$P= \begin{bmatrix} 0,1 & 0,3 & 0,0 & 0,6 \\ 0,2 & 0,4 & 0,1 & 0,3 \\ 0,0 & 0,8 & 0,0 & 0,2 \\ 0,2 & 0,0 & 0,2 & 0,6 \end{bmatrix}$$

with dots:
$$P= \begin{bmatrix} 0.1 & 0.3 & 0.0 & 0.6 \\ 0.2 & 0.4 & 0.1 & 0.3 \\ 0.0 & 0.8 & 0.0 & 0.2 \\ 0.2 & 0.0 & 0.2 & 0.6 \end{bmatrix}$$

\end{document}


As you can see numbers with a comma as a decimal separator are wider than those with a dot. How can I change space after a comma to be equal to space after a dot?

-
–  Hendrik Vogt Jun 20 '12 at 7:21

You need an intelligent comma-package like icomma or ncccomma.

You can also adapt the code from Claudio Beccari's article in The PracTEX Journal, 2011, No. 1.

\usepackage{icomma}


or

\usepackage{ncccomma}


If you have none of those packages installed, you can add Claudio Beccari's code to your preamble (I have removed the comments and added \makeatother as the last line):

\makeatletter
\DeclareMathSymbol{\punctcomma}{\mathpunct}{letters}{"3B}
\DeclareMathSymbol{\decimalcomma}{\mathord}{letters}{"3B}
\AtBeginDocument{\mathcode‘\,="8000}
{\catcode‘\,=\active \gdef,{\futurelet\let@token\m@thcomma}}
\def\m@thcomma{\let\@tempB\punctcomma
\@tfor\@tempA:=0123456789\do{%
\expandafter\ifx\@tempA\let@token\let\@tempB\decimalcomma
\@break@tfor\fi}\@tempB}
\makeatother


Hopefully, this will help.

-

I don't know what intelligence is hidden in the mentioned intelligent packages, but I guess that it can be implemented by the four lines:

\def\mathcomma{\futurelet\next\mathcommaA}
\def\mathcommaA{\mathchar, \expandafter\ifx\space\next\,\fi}
{\catcode,=13 \global\let,=\mathcomma}
\mathcode,="8000

without space after comma: $1,234$ with spaces: $1, 2, 3$.

\bye

-
This is essentially the same as the code in icomma.sty. –  egreg Feb 5 at 13:14
The icomma.sty uses sequences \ProvidesPackage, \AtBeginDocument and many @` like sequences. This makes the macro file format dependent. My macro is format independent (as usual). This is substantial difference. –  wipet Feb 5 at 15:50