2

I frequently use the eurosym package to typeset Euro values.

\documentclass{article}
\usepackage{eurosym}
\begin{document}    
\EUR{100000}
\end{document}

This translates into '€ 100000'.

It however misses the option for thousands separators. For an English text, I'd like to convert this into '€ 100,000'. In a German text, one would rather do '100.000 €'. The placement of the Euro sign is already taken care of by the eurosym package.

Is there a way (ideally, a package) that provides this or does someone have an idea how to achieve this easily?

E. Sommer
  • 199

2 Answers2

4

Just use the same eurosym package along with sistyle package in which you define the separator location to be thousand using SIthousandsep{,}. Then you can use this

\documentclass{article}
\usepackage{eurosym}
\usepackage{sistyle}
\SIthousandsep{,}
\newcommand{\euros}[1]{\euro{\num{#1}}}

\begin{document}
I have a 5-figure pay check with \euros{40000}.

Now I am a millionaire with \euros{4000000}.

I wish I own a Ferrari worth of \euros{400000000000} (I have no idea how much that costs).
\end{document}

to get:

enter image description here

PS: I prefer to use \euro{...} instead of \EUR{...}. Because, the latter gives an additional spurious space which, I personally do not prefer ;)

The output with \EUR{...}:

enter image description here

Also, note that you can use just \euro as well.

  • 1
    I like \EUR{} because that way I don't have to bother about the language I'm writing in ;) – E. Sommer Jan 15 '19 at 21:12
  • What do you mean by that? – Raaja_is_at_topanswers.xyz Jan 15 '19 at 21:20
  • Because \EUR{} recognizes the babel setting and sets the euro sign to the left or the right accordingly. – E. Sommer Jan 15 '19 at 21:27
  • I don't know much about that, but it introduces an unwanted spurious space. – Raaja_is_at_topanswers.xyz Jan 15 '19 at 21:37
  • 1
    Sorry for raising this old question again. But with your code \euros{1000} does not have a separator. How does one make this work for four digits? – E. Sommer Mar 06 '19 at 11:00
  • 1
    @E.Sommer Very nice remark! I think this deserves to be a new question. Right now I dont have a solution for that. But I will work on that. – Raaja_is_at_topanswers.xyz Mar 06 '19 at 11:32
  • Works well but not in \bf or \textbf mode. How could I also get bold numbers? – Supernormal Jun 16 '20 at 18:37
  • @Supernormal I don't know which distribution you are using. But with pdftex 3.14159265-2.6-1.40.21 (MiKTeX 2.9.7380 64-bit) I am able to render bold fonts by enclosing them as {\bf\euros{.}} or \textbf{\euros{.}} to get https://imgur.com/a/8j1TJ15. – Raaja_is_at_topanswers.xyz Jun 17 '20 at 06:06
  • MWE: `\documentclass{article} \usepackage{eurosym} \usepackage{sistyle} \SIthousandsep{,} \newcommand{\euros}[1]{\euro{\num{#1}}}

    \begin{document} I have a 5-figure pay check with \euros{40000}.

    Now I am a millionaire with \euros{4000000}.

    I wish I own a Ferrari worth of \textbf{\euros{400000000000}} (I have no idea how much that costs).

    I wish I own a Ferrari worth of {\bf\euros{400000000000}} (I have no idea how much that costs). \end{document}`

    – Raaja_is_at_topanswers.xyz Jun 17 '20 at 06:06
4

Combine eurosym with siunitx:

\documentclass{article}
\usepackage{eurosym}
\usepackage{siunitx}

\newcommand{\eur}[2][]{\EUR{\num[#1]{#2}}}

\begin{document}

\eur{10000}

\eur[group-separator={,}]{10000}

\sisetup{group-separator={,}}

\eur{10000}

\end{document}

A particular option for number formatting can be passed as optional argument or set by default with \sisetup.

enter image description here

The same but with \usepackage[right]{eurosym}:

enter image description here

egreg
  • 1,121,712