消除“siunitx”和“physics”包 \qty 警告

消除“siunitx”和“physics”包 \qty 警告

我想使用siunitxphysics包,使用 的 \qty 定义siunitx。在发出警告后

siunitx 软件包警告:检测到“physics”软件包:省略 \qty 的定义。如果您想要将 \qty 与 siunitx 定义一起使用,请将 \AtBeginDocument{\RenewCommandCopy\qty\SI} 添加到您的前言中。

我添加了推荐的一行

\AtBeginDocument{\RenewCommandCopy\qty\SI}

导入两个包后立即出现。我的问题:警告仍然出现。我尝试静音警告,但即使是我所知道的最残酷的方式

\documentclass[a4paper,11pt,oneside,final,openbib,pdftex]{scrbook}
\usepackage{silence}
\WarningsOff*
\usepackage{siunitx}
\usepackage{physics}
\AtBeginDocument{\RenewCommandCopy\qty\SI}
\begin{document}
A few chapters and a bib
\end{document}

错误仍然存​​在。显而易见的是:我只想以类似的方式消除这个特定的警告\WarningFilter{siunitx}{Detected},但由于关闭所有警告也无济于事,因此不用说,这个版本不能很好地工作。

答案1

来自的消息siunitx使用expl3消息系统,对此我们silence并不了解。但是,此系统设置为允许用户控制消息显示,因此我们可以简单地重定向消息:

\documentclass{article}
\usepackage{siunitx}
\usepackage{physics}
\AtBeginDocument{\RenewCommandCopy\qty\SI}
\ExplSyntaxOn
\msg_redirect_name:nnn { siunitx } { physics-pkg } { none }
\ExplSyntaxOff
\begin{document}
A few chapters and a bib
\end{document}

相关内容