使用较轻量级时 SIunitx 出现错误

使用较轻量级时 SIunitx 出现错误

将 SIunitx 包与 montserrat 包一起使用不会产生预期的结果:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[defaultfam,light,scale=0.85]{montserrat}
\usepackage{siunitx}
\sisetup{%
 mode = math, % Same error if mode = text is used
% detect-all, % When, uncommented, the error described below occurs
% detect-weight,  % When, uncommented, the error described below occurs
}  

\begin{document}
This is the weight and family of text desired but when siunitx shows heavier weight: \SI{75}{\micro\metre}
\end{document}

生成:

图像显示单位和数字的字体粗细不正确。

当使用选项detect-weightdetect-all时,会产生以下错误:

[no file]:18: Undefined control sequence. [...hows heavier weight: \SI{75}{\micro\metre}]
[no file]:18: Undefined control sequence. [...hows heavier weight: \SI{75}{\micro\metre}]

尽管存在编译错误,但 PDF 仍显示所需的结果:

预期结果

日志文件显示:

Package: siunitx 2018-05-11 v2.7q A comprehensive (SI) units package

并报告以下错误:

! Undefined control sequence.
\__siunitx_font_weight: ->\lseries 

l.18 ...hows heavier weight: \SI{75}{\micro\metre}

答案1

提供缺失命令的定义:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[defaultfam,light,scale=0.85]{montserrat}
\usepackage{siunitx}
\sisetup{%
 mode = math, % Same error if mode = text is used
 detect-all, % When, uncommented, the error described below occurs
 %detect-weight,  % When, uncommented, the error described below occurs
}

\DeclareRobustCommand\lseries{\fontseries{l}\selectfont}

\begin{document}
This is the weight and family of text desired but when siunitx shows heavier weight: \SI{75}{\micro\metre}
\end{document}

答案2

您需要siunitx使用 选项进行加载。(有关、等之间的区别,detect-mode请参阅软件包使用指南第 17 页底部和第 18 页顶部。)siunitxdetect-modedetect-weight

在此处输入图片描述

\documentclass{article}
\usepackage{geometry} % optional
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[defaultfam,light,scale=0.85]{montserrat}
\usepackage{siunitx}
\sisetup{ mode = math , detect-mode }  

\begin{document}
This is the weight and family of text desired. siunitx now shows the correct, i.e, thin weight: \SI{75}{\micro\metre}
\end{document}

答案3

您可以mode = text不使用任何detect-*选项,即使在数学模式下使用该单位也会获得相同的输出:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[defaultfam,light,scale=0.85]{montserrat}
\usepackage{siunitx}
\sisetup{ mode = text }

\begin{document}
This is the weight and family of text desired but when siunitx shows
heavier weight: \SI{75}{\micro\metre} $\SI{75}{\micro\metre}$
\end{document}

在此处输入图片描述

相关内容