16

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

8
  • You get an pound symbol with pdflatex
    – user31729
    Jun 7, 2015 at 10:25
  • But not xelatex, at least here Jun 7, 2015 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, 2015 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 $ Jun 7, 2015 at 12:20
  • @AubreyBlumsohn Use egreg's font name. There is a difference
    – percusse
    Jun 7, 2015 at 12:32

2 Answers 2

12

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

2

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} 

enter image description here

6
  • 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. Jun 7, 2015 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, 2015 at 13:55
  • 2
    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, 2015 at 13:58
  • (Sorry for the off-topic remark but:) Thank you @Bernard! I've been trying to get the rupee-sign (₹) prefixed through the SI but drew a literal blank no matter how I tried defining it --- yet ₹ worked well outside the SI -command. Surrounding it with \text{} did the trick!
    – krissen
    Jul 2, 2020 at 15:58
  • (Continuing the off-topic remark:) Another way of fixing it was to inform the SI command that it wasn't in math-mode. For instance by using the option detect-mode=true for \SI. Then I expect \pounds would've worked as well? At least ₹ did.
    – krissen
    Jul 4, 2020 at 13:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .