siunitx 不偵測數字樣式

siunitx 不偵測數字樣式

Siunitx 無法辨識舊式數字,儘管進行了設置detect-all,你能幫我嗎?

MNWE:

\documentclass{standalone}

\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}

\newfontfamily\oldstyle[Numbers={Monospaced,OldStyle}]{TeX Gyre Pagella}

\usepackage[detect-all]{siunitx}

\begin{document}
  \oldstyle\num{123}123
\end{document}

這導致:

在此輸入影像描述

答案1

只要說服西尤尼克斯透過以下方式使用新建立的字體系列:

\sisetup{text-rm=\oldstyle}

完整範例:

\documentclass{standalone}

\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}

\newfontfamily\oldstyle[Numbers={Monospaced,OldStyle}]{TeX Gyre Pagella}

\usepackage[detect-all]{siunitx}

\AtBeginDocument{
\sisetup{text-rm=\oldstyle}
}

\begin{document}
  \oldstyle\num{123}123
\end{document}

在此輸入影像描述


正如手冊中所述,您被迫這樣做:

siunitx 套件控制用於獨立於周圍材料列印輸出的字體。標準方法是完全忽略周圍環境,並使用當前的正文字體。

為了解決這個問題,有以下幾種可能性:

detect-all組合了以下四個單一命令

  • detect-weight
  • detect-family
  • detect-shape
  • detect-mode

所以它不會檢測到全部- 因此這個名字有點誤導。

數字樣式是一種相當特殊的字體設置,未包含在detect-all.


作為西尤尼克斯旨在用於數字和單位的科學記數法,這是可以理解的,數字樣式不能輕易更改,因為它看起來不那麼容易“科學”不再了。我在論文中使用舊式數字以及章節編號等,實際上我siunitx一開始就希望適應這種設置,但很高興它沒有改變。

相關內容