unicode-math:在數學模式下使用文字字型表示數字

unicode-math:在數學模式下使用文字字型表示數字

將 XeTeX 與fontspec和 一​​起使用unicode-math,我想使用文檔主要字體 for數位(數字)在數學模式下。另外,我想\text{}在數學模式下使用襯裡數字,而文件的預設值是舊樣式數字。我怎樣才能實現這種行為?

我嘗試插入\setmathfont[range=\mathup/{num}]{Linux Libertine O},但沒有給出所需的結果。

這是一個MWE,指出了問題:

\documentclass{article}
\usepackage{iftex}

\usepackage{libertine}
\usepackage{fontspec} 
\setmainfont[Numbers=OldStyle]{Linux Libertine O} 

\usepackage{amsmath}

\usepackage{unicode-math}
% Here I try to set up the normal text font for digits in mathmode: 
\setmathfont[range=\mathup/{num}]{Linux Libertine O}

\parindent0pt

\begin{document}

This is \ifXeTeX XeTeX\fi\ifLuaTeX LuaTeX\fi 
with \fontname\font
\bigskip

Text numbers: 
0123456789; italic: \textit{0123456789}; bold: \textbf{0123456789} 

Text numbers lining: 
\liningnums{0123456789; italic: \textit{0123456789}; bold: 
\textbf{0123456789}}

Numbers in mathmode: $0123456789$ (ok)\\
mathit: $\mathit{0123456789}$ (wrong font)\\
mathbf: $\mathbf{0123456789}$ (wrong font)\\
mathrm: $\mathrm{0123456789}$ (wrong font)\\
text (math): $\text{0123456789}$ (should be lining)

In big equation, fonts for big brackets $\big( \Big( \bigg( \Bigg($ are
missing: 
\[
\left(\frac{12a}{34b}\right)
\]

\end{document}

使用 XeTeX,結果是:

在此輸入影像描述

所以有3個問題:

  1. Linux Libertine O數字不會出現在\mathrm\mathit\mathbf等。
  2. 大括號不起作用。 (請參閱下面的更多內容。)
  3. \text{}儘管文檔編號樣式是 OldStyle,有沒有辦法在 mathmode 中實現 Lining 編號?

關於問題 1,這是因為range=\mathup/{num}僅適用於直立的數學文字。有誰知道如何將此命令應用於所有範圍內的所有數字?僅使用range={num}會導致錯誤。

關於問題2,我還有兩個資訊。 A) 在同一個檔案上使用 LuaTeX,括號確實出現,但沒有縮放:

在此輸入影像描述

B)如果我註解掉該行\setmathfont[range=\mathup/{num}]{Linux Libertine O},則問題根本不會發生。這表明括號機制會受到更改數字字體的影響,但這不應該是這樣,對嗎?

在此輸入影像描述

順便說一下,這個問題並不是特定於Linux Libertine O.當我用SabonNextLTPro作主文檔字體時它也出現了。

答案1

同時,在有人提出想法之前,我想我會分享一個解決方法。它基本上恢復到mathspec而不是unicode-math.幾乎所有東西都可以開箱即用,只需三行:

\documentclass{article}
\usepackage{iftex}

\usepackage[no-math]{fontspec} 
\usepackage{libertine}
\setmainfont[Numbers=OldStyle]{Linux Libertine O} 

\usepackage{amsmath}
\usepackage{mathspec}
\setmathfont(Digits){Linux Libertine O}

\parindent0pt

\begin{document}

This is \ifXeTeX XeTeX\fi\ifLuaTeX LuaTeX\fi 
with \fontname\font
\bigskip

Text numbers: 
0123456789; italic: \textit{0123456789}; bold: \textbf{0123456789} 

Text numbers lining: 
\liningnums{0123456789; italic: \textit{0123456789}; bold: 
\textbf{0123456789}}

Numbers in mathmode: $0123456789$ (ok)\\
mathit: $\mathit{0123456789}$ (correct font but no italic)\\
mathbf: $\mathbf{0123456789}$ (correct font but no boldface)\\
mathrm: $\mathrm{0123456789}$ (ok)\\
text (math): $\text{0123456789}$ (should be lining)

In equations, testing fonts for big brackets $\big( \Big( \bigg( \Bigg($: 
\[
\left(\frac{12a}{34b}\right)
\]

\end{document}

在此輸入影像描述

相關內容