这只是一个奇怪的现象。我使用 siuniutx 来格式化货币(每三位数字留出一些空格,并且无论输入什么都保留两位小数)。但是前缀不像通常的 \pounds 符号(将其转换为 $)。直接使用 £ 就可以了。我只是想知道为什么会这样。
\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}
答案1
由于历史原因,由于通常\mathrm
字体是 OT1 编码的,因此该命令\mathsterling
确实如此\mathit{\mathchar"7024}}
(即它使用美元符号,在斜体 OT1 字体中是磅符号)。
修正错误的定义。
\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}
答案2
我可以提出一个\Pounds
宏,带有一个(数字)可选参数:如果没有参数,则与 a 相同\pounds
;如果有一个数字,它会添加一个格式化的数字,前面是一个不可破坏的细空格:
\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}