[Tex/LaTex] Currency formatting with siunitx

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}

enter image description here

Best Answer

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}

enter image description here

Related Question