4

The decimal separator of the eurosym package is either the comma or the dot. If you write \EUR{3.2} it is written with a dot, and if you write \EUR{3,2}, it is written with a comma according to the French typography.

\documentclass[a4paper, 11pt]{article}  % Présentation générale et mise en page

\usepackage[right]{eurosym}         
\usepackage[french]{babel}


\begin{document}

Avec un point : \EUR{10.30} 

Avec une virgule : \EUR{10,30}
\end{document}

Output:

eurosym-decimal-separator

So there is no problem from that point of view.

However, with LaTeX the decimal separator is by default a dot. For example, the xlop package, tikz and almost all other packages respect this convention. And in order to respect the local typography, French for example, a global command allows to modify the decimal separator and to display a comma in place of the dot. This is consistent since all numbers are coded identically and displayed using local typography.

For example, with xlop these command is \opset{decimalsepsymbol={,}}

Is it possible to do the same with eurosym? That is, how to write \EUR{13.25} in the code and display 13,25 € in the text?

If not, which package allows you to do this?

Translated with www.DeepL.com/Translator

AndréC
  • 24,137

1 Answers1

7

Integrate eurosym with siunitx that makes \num available. However you input the number, it will be output with the chosen decimal marker, here according to locale=FR.

\documentclass[a4paper, 11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{siunitx}
\usepackage[right]{eurosym}

\sisetup{locale=FR}

\makeatletter
\renewcommand{\EUR}[2][]{%
  \if@EURleft\euro\,\fi
  \num[#1]{#2}%
  \if@EURleft\else\,\euro\fi
}
\makeatother

\begin{document}

Avec un point : \EUR{10.30}

Avec une virgule : \EUR{10,30}
\end{document}

enter image description here

The redefined \EUR command has also an optional argument for setting options for \num; see the documentation of siunitx: \EUR[<options>]{<number>}.

If you want to use numprint, just change \num (and the optional argument makes no sense here):

\makeatletter
\renewcommand{\EUR}[1]{%
  \if@EURleft\euro\,\fi
  \numprint{#1}%
  \if@EURleft\else\,\euro\fi
}
\makeatother
egreg
  • 1,121,712