![OldStyle 数字、Fira Sans 字体和 siunitx 包:错误的 % 符号](https://linux22.com/image/325846/OldStyle%20%E6%95%B0%E5%AD%97%E3%80%81Fira%20Sans%20%E5%AD%97%E4%BD%93%E5%92%8C%20siunitx%20%E5%8C%85%EF%BC%9A%E9%94%99%E8%AF%AF%E7%9A%84%20%25%20%E7%AC%A6%E5%8F%B7.png)
我正在处理一个经常使用百分比的文档。为此,我想使用软件包,siunitx
以便我可以编写\SI{56}{\%}
。我还喜欢使用 OldStyle(或 Lining)数字。目前我正在使用 XeLaTeX 和 Mozilla Fira Sans 字体,一切似乎都运行良好,除了 % 符号似乎来自默认的 Computer Modern 字体。
这是我的 MWE:
\documentclass[a4paper]{scrartcl}
\usepackage[]{mathspec}
\setmainfont[Numbers=OldStyle,BoldFont={Fira Sans SemiBold}]{Fira Sans Book}
\setsansfont[Numbers=OldStyle,BoldFont={Fira Sans SemiBold}]{Fira Sans Book}
\setmonofont{Fira Mono}
\setmathsfont(Digits,Latin,Greek){Fira Sans Book}
\setmathsf[]{Fira Sans Book}
\usepackage[]{siunitx}
\begin{document}
\begin{itemize}
\item Some numbers in text mode: 1234567890.
\item Some numbers using the \texttt{siunitx} package:
\SI{1234567890}{m/s}. This works well.
\item However, specifying percentages doesn't use the \% symbol I
would like: \SI{24.5}{\%} or \SI{24.5}{\percent}. Compared to
regular text: 24.5 \%.
\item Another font check: SI \SI{9}{million} vs regular 9 million.
\end{itemize}
\end{document}
知道如何告诉mathspec
包(或其他东西)从 Fira Sans 字体中获取 % 符号吗?我也尝试了包detect-all
的选项siunitx
,但也没有用。
答案1
重新定义\%
做正确的事:
\documentclass[a4paper]{scrartcl}
\usepackage[]{mathspec}
\setmainfont[Numbers=OldStyle,BoldFont={Fira Sans SemiBold}]{Fira Sans Book}
\setsansfont[Numbers=OldStyle,BoldFont={Fira Sans SemiBold}]{Fira Sans Book}
\setmonofont{Fira Mono}
\setmathsfont(Digits,Latin,Greek){Fira Sans Book}
\setmathsf[]{Fira Sans Book}
\usepackage[]{siunitx}
\DeclareRobustCommand{\%}{\ifmmode\textnormal{\symbol{`\%}}\else\symbol{`\%}\fi}
\DeclareSIUnit{\percent}{\%}
\begin{document}
\begin{itemize}
\item Some numbers in text mode: 1234567890.
\item Some numbers using the \texttt{siunitx} package:
\SI{1234567890}{m/s}. This works well.
\item However, specifying percentages doesn't use the \% symbol I
would like: \SI{24.5}{\%} or \SI{24.5}{\percent}. Compared to
regular text: 24.5 \%.
\item Another font check: SI \SI{9}{million} vs regular 9 million.
\end{itemize}
\end{document}