用 fontspec 取代 siunitx 中使用的文字字型中缺少的字元(減號)

用 fontspec 取代 siunitx 中使用的文字字型中缺少的字元(減號)

我被迫使用廣告(大學)我的簡報中的字體,顯然不包含專用\minus符號,該符號由。 (雖然我不確定它是\minus還是其他什麼。)所以如果我輸入

\SI{-1984}{m^{-42}}

我沒有顯示任何減號。不幸的是我沒有找到任何具有相同行為的免費字體。但我希望你明白我的意思。

我怎樣才能包括失蹤的減號從另一種字體到我的文字字體中得到能正常工作嗎?


這是一個 MWE:

\documentclass{beamer}

\usefonttheme{professionalfonts}
\usepackage{siunitx}
\usepackage{fontspec}
\usepackage{unicode-math}

\setmainfont{Univers 45 Light} 
\setmathfont{XITS Math}

\setbeamerfont{normal text}{family=\rmfamily,series=\normalfont}

\AtBeginDocument{
\usebeamerfont{normal text}
\sisetup{detect-all}
\sisetup{math-rm=\mathrm, text-rm=\rmfamily}
\sisetup{per-mode=fraction,fraction-function=\sfrac}
}

\begin{document}

\begin{frame}
The dash - is working. But the minus sign in \alert{siunitx} (e.g. \SI{-1984}{m^{-42}}) isn't, apart from when it is used in math-mode (e.g. $\SI{-1984}{m^{-42}}$). But in text I'd like to use my text font.
\end{frame}

\end{document}

給我輸出:

在此輸入影像描述

我用其他字體就沒有這個問題。


我嘗試了各種方法,前兩者給了我語法錯誤:

\setmainfont[\minus="2212]{XITS Math}

或者就像我習慣對數學字體所做的那樣:

\setmainfont[range={="2212}]{XITS Math}

我也找到了這段程式碼,

\newunicodechar{"2212}{{\fontspec{XITS Math}"2212}}
\newunicodechar{\minus}{{\fontspec{XITS Math}\minus}}
\newunicodechar{-}{{\fontspec{XITS Math}-}}

他們都不工作。

還有更多建議嗎?


我使用的字體確實包含該字符\char"2013,但它不包含\char"2212,但在我看來,這是由當輸入減號時。

艾格格的建議

\usepackage{newunicodechar}
\newunicodechar{^^^^2212}{\char"2013}

為單位工作

\SI{-1984}{m^{^^^^2212 42}}) 

但不適用於數字,因為^^^^2212它是無效的數字字元。

相關內容