通过这种配置,除了使用之外,我无法使用粗体 siunitx \pmb
,但会产生丑陋的副作用:
\documentclass[margin=5pt]{standalone}
\usepackage{fourier}
\usepackage{fontspec}
\setmainfont{Erewhon}[
Extension=.otf,
UprightFont=*-Regular,
ItalicFont=*-Italic,
BoldFont=*-Bold,
BoldItalicFont=*-BoldItalic,
SlantedFont=*-RegularSlanted,
BoldSlantedFont=*-BoldSlanted,
SmallCapsFont=*-SmallCaps,
SmallCapsFont=*-Regular,
SmallCapsFeatures={Letters=SmallCaps}
]
\setsansfont{texgyreheros}[
Scale=MatchLowercase,% or MatchUppercase
Extension=.otf,
UprightFont=*-regular,
ItalicFont=*-italic,
BoldFont=*-bold,
BoldItalicFont=*-bolditalic,
]
\usepackage{amsmath,amsfonts,amssymb,mathrsfs}
\usepackage{bm} % Bold math with \bm{}
\RequirePackage{siunitx} % \num{} ...
\sisetup{%
unit-mode = text,%
% detect-weight=true,
% detect-family=true,
% detect-inline-weight=math,
locale=FR,%
%detect-all,% Problème avec euro, inutile
inter-unit-product = \ensuremath{{}\cdot{}},%
group-minimum-digits=4,
text-angstrom={Å},math-angstrom={\text{Å}}
}
\begin{document}
$\pmb{\SI{2109}{kg}}$
\end{document}
答案1
使用[detect-all]
选项siunitx
然后
\let\svSI\SI
\renewcommand\SI[2][]{\bgroup\edef\tmpA{#1}\edef\tmpB{#2}\SIx}
\newcommand\SIx[2][]{%
\textrm{\bfseries\boldmath\expandafter\svSI\expandafter[\tmpA]{\tmpB}[#1]{#2}}\egroup}
在序言中。已编辑以自动对粗体进行分组限制。已编辑以在数学和文本模式下工作。下面的 MWE 演示了修订后的所有可选参数均能\SI
正常工作。
\documentclass[margin=5pt]{article}
\usepackage{fourier}
\usepackage{fontspec}
\setmainfont{Erewhon}[
Extension=.otf,
UprightFont=*-Regular,
ItalicFont=*-Italic,
BoldFont=*-Bold,
BoldItalicFont=*-BoldItalic,
SlantedFont=*-RegularSlanted,
BoldSlantedFont=*-BoldSlanted,
SmallCapsFont=*-SmallCaps,
SmallCapsFont=*-Regular,
SmallCapsFeatures={Letters=SmallCaps}
]
\setsansfont{texgyreheros}[
Scale=MatchLowercase,% or MatchUppercase
Extension=.otf,
UprightFont=*-regular,
ItalicFont=*-italic,
BoldFont=*-bold,
BoldItalicFont=*-bolditalic,
]
\usepackage{amsmath,amsfonts,amssymb,mathrsfs}
\usepackage{bm} % Bold math with \bm{}
\RequirePackage[detect-all]{siunitx} % \num{} ...
\sisetup{%
unit-mode = text,%
% detect-weight=true,
% detect-family=true,
% detect-inline-weight=math,
locale=FR,%
%detect-all,% Problème avec euro, inutile
inter-unit-product = \ensuremath{{}\cdot{}},%
group-minimum-digits=4,
text-angstrom={Å},math-angstrom={\text{Å}}
}
\let\svSI\SI
\renewcommand\SI[2][]{\bgroup\edef\tmpA{#1}\edef\tmpB{#2}\SIx}
\newcommand\SIx[2][]{%
\textrm{\bfseries\boldmath\expandafter\svSI\expandafter[\tmpA]{\tmpB}[#1]{#2}}\egroup}
\begin{document}
Math mode: $\SI{2109}{kg}$
Text mode: \SI[per-mode=symbol]{2109}{\kg \per \s} not bold $xy$
Text mode: \SI[per-mode=fraction]{2109}[\$]{\kg \per \s} not bold $xy$
\end{document}