# Currency formatting with siunitx

This is just an oddity. I use siuniutx to format currencies (with some spacing every three digits, and to 2 decimals irrespective of input). However the prefix does not like the usual \pounds symbol (converting this to $). A straight £ works fine. I just wondered why this is the case. \documentclass[a4paper,12pt]{article} \usepackage{fontspec} \usepackage{libertine} \usepackage{siunitx} \begin{document} The \pounds\ pounds macro behaves as expected And this is \pounds40434.5345 The dollar prefix works fine: \SI[round-precision=2,round-mode=places,round-integer-to-decimal]{34324}[\$]{}

But the pounds prefix is imperialistic: \SI[round-precision=2,round-mode=places,round-integer-to-decimal]{34324}[\pounds]{}

But straight pound sign is ok: \SI[round-precision=2,round-mode=places,round-integer-to-decimal]{34324}[£]{}
\end{document}


• You get an pound symbol with pdflatex – user31729 Jun 7 '15 at 10:25
• But not xelatex, at least here – Aubrey Blumsohn Jun 7 '15 at 10:51
• If you are using XeLaTeX leave out the libertine package then use the settings in @egreg's answer in tex.stackexchange.com/questions/105970/… . He mentions that they should be equivalent however I always had various other problems as you have here. – percusse Jun 7 '15 at 11:35
• At least here replacing libertine with \setmainfont[Ligatures=TeX]{Linux Libertine O} yields the same outcome albeit with a non-italic $. Using a completely different font package (\usepackage[lining,proportional]{ebgaramond}) again yields the$ – Aubrey Blumsohn Jun 7 '15 at 12:20
• @AubreyBlumsohn Use egreg's font name. There is a difference – percusse Jun 7 '15 at 12:32

For historical reasons due to the fact that usually the \mathrm font is OT1 encoded, the command \mathsterling does \mathit{\mathchar"7024}} (that is it uses the dollar sign, which in the italic OT1 font is a pound sign).

Fix the wrong definition.

\documentclass[a4paper,12pt]{article}
\usepackage{fontspec}
\usepackage{libertine}
\usepackage{siunitx}

\renewcommand{\mathsterling}{\mathrm{\mathchar"70A3}}

\begin{document}
The \pounds\ pounds macro behaves as expected

And this is \pounds40434.5345

The dollar prefix works fine:
\SI[round-precision=2,round-mode=places,round-integer-to-decimal]{34324}[\\$]{}

But the pounds prefix is imperialistic:
\SI[round-precision=2,round-mode=places,round-integer-to-decimal]{34324}[\pounds]{}

But straight pound sign is ok:
\SI[round-precision=2,round-mode=places,round-integer-to-decimal]{34324}[£]{}

\end{document}


I can propose a \Pounds macro, with a (numerical) optional argument: if there's no argument, it is the same a \pounds; if there's a number it adds a formatted number, preceded by an unbreakable thin space:

\documentclass[a4paper,12pt]{article}
\usepackage{fontspec}
\usepackage{libertine}
\usepackage{siunitx}
\usepackage{xparse}

\NewDocumentCommand\Pounds{o}{%
\pounds\IfNoValueTF{#1}%
{\relax}{\,\num[round-precision=2,round-mode=places,round-integer-to-decimal]{#1}}}

\begin{document}

But the pounds prefix is imperialistic:
\Pounds[34324]

\Pounds34324

\end{document}


• OK, that's a neat macro (and it works, and I'll use it). But it is essentially bypassing the standard prefixing mechanism in siunitx, and doesn't explain why that mechanism doesn't work for \pounds (in any font tried) but does for £, and why that failure is only manifest in XeLaTex. – Aubrey Blumsohn Jun 7 '15 at 13:37
• I have the same problem in compiling with pdflatex, using fourier, ebgaramond, erewhon. The problem doesn't exist only with latin modern and computer modern. I would think the problem is in the \pounds macro itself (using a specific TeX encoding?). Anyway, the prefix system doesn't add a thin space between currency symbol and number, as it should. – Bernard Jun 7 '15 at 13:55
• I've just discovered the problem disappeats with this code: \SI[round-precision=2,round-mode=places,round-integer-to-decimal]{34324}[\text{\pounds}]{}. – Bernard Jun 7 '15 at 13:58