[Tex/LaTex] Comma in math mode

punctuation

In some countries one use comma as decimal separator instead of a dot.

I ususally use:

%%%% Une vrai virgule pour les décimaux
\DeclareMathSymbol{@}{\mathord}{letters}{"3B}

and $3@2$ to obtain 3,2
instead of $3,2$ that gives 3, 2 <- a uggly useless space after comma

I just find this :

\mathcode`\.="8000
{\catcode`\.=\active
\gdef.{,}}

That replaces automatically a dot by a comma in math mode, but with the ungly useless space.

Is there a way to combine both technics to have an automatic sustitution with a proper comma ?

Edit Sorry !

It was obvious :

%%%% Une vrai virgule pour les décimaux
\DeclareMathSymbol{@}{\mathord}{letters}{"3B}
\mathcode`\.="8000
{\catcode`\.=\active
\gdef.{@}}

Could this code have boder effect ?
Is there a better or other way to get this ?

Best Answer

To answer your original question. You could redefine . to produce another symbol in math mode.

\DeclareMathSymbol{.}{\mathord}{letters}{"3B}

Here in a MWE

\documentclass{article}
\mathchardef\period=\mathcode`.
\DeclareMathSymbol{.}{\mathord}{letters}{"3B}
\begin{document}
$3.2$
$3\period2$
\end{document}

enter image description here

Related Question