siunitx 不偵測字體和大小

siunitx 不偵測字體和大小

我正在使用 PNAS 的模板(http://www.pnas.org/site/authors/LaTex.xhtml)在 sharelatex 上以及當我添加如下單位時:

\SI{15}{\mL}

它們沒有正確縮放,如附圖所示。
siunitx 未正確縮放的範例
此外,有沒有辦法可以強制 siunitx 使用周圍的字體。我嘗試在序言中使用:

\sisetup{detect-weight=true, detect-family=true}

沒有運氣。
任何幫助,將不勝感激。

編輯 1:新增了最小範例

\documentclass{pnastwo}
\usepackage[dvips]{graphicx}
\usepackage{amssymb,amsfonts,amsmath}
\usepackage{gensymb,fixltx2e}
\usepackage{fontspec}
\usepackage{siunitx}
\sisetup{detect-weight=true, detect-family=true}

\begin{document}
\begin{article}
\begin{materials}
This is a minimal example. The following units \SI{15}{\mL} do not render with the same typeface and size as the surrounding text. 
\end{materials}
\end{article}
\end{document}

答案1

該類別不使用 nfss 來定義字體,因此 siunitx 絕對沒有機會檢測字體(並且作為側面警告:小心非 ascii 字元。與 xelatex/lualatex 組合時,它們可能會出現錯誤或一起失踪)。您可以透過重新定義字體命令來解決該問題:

\documentclass{pnastwo}

\usepackage{graphicx}
\usepackage{amssymb,amsfonts,amsmath}
\usepackage{gensymb,fixltx2e}
\usepackage{fontspec}
\renewcommand\materialfont{\sffamily\fontsize{7pt}{\baselineskip}\selectfont}
\usepackage{siunitx}
\sisetup{detect-weight=true, detect-family=true}

\begin{document}
\begin{article}
\begin{materials}
This is a minimal example. The following units \SI{15}{\mL} do not render with the same typeface and size as the surrounding text.
\end{materials}
\end{article}
\end{document}

答案2

(評論太長,因此作為某種答案發布。)

您的文件設定中肯定存在一些到目前為止您還沒有告訴我們的事情。文檔pnastwo類別本身不會擾亂字體,至少不會影響套件的巨集\siunitx

請告訴我們——最好以微量元素-- 如何將文字字體變更為無襯線字體。

在此輸入影像描述

\documentclass{pnastwo}
\usepackage[detect-family=true]{siunitx}
\begin{document}
\sffamily
abc

\SI{15}{\milli\liter}
\end{document}

相關內容