我正在处理一个经常使用百分比的文档。为此,我想使用软件包,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}