使用 unicode-math 重新定義 \prime

使用 unicode-math 重新定義 \prime

我正在使用unicode-math(與 XeLaTeX)來設定我的文字和數學字體。但是,用作Garamond-math數學字體時,我發現該\prime符號距離字母太近:

在此輸入影像描述

我正在嘗試重新定義\prime命令,如果可能的話,我想'在數學模式下重新映射,以便它給出正確的間距。然而,重新定義 的「通常」解決方案\prime,即 (MWE)

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{Garamond-Math.otf}[StylisticSet={5,7,9}]
\let\originalprime\prime
\def\prime{\mkern3mu\originalprime\mkern-3}
\begin{document}

$f'(x)$

\end{document}

但這個解決方案在這種情況下似乎不起作用。我也嘗試過

\usepackage{newunicodechar}
\AtBeginDocument{\newunicodechar{′}{\mkern3mu\prime\mkern-3u}}

但同樣沒有效果。

答案1

unicode-math命令\prime是根據內部函數定義的,在f'(x)處理時使用該函數。所以重新定義\prime沒有任何作用,除非你明確地使用它。

不幸的是,沒有用於修改行為的介面。但以下內容適用於目前版本的unicode-math.然而,由於存取私有函數,不能保證在未來版本中保持穩定。

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{Garamond-Math.otf}[StylisticSet={5,7,9}]

\ExplSyntaxOn
\cs_set:Npn \__um_prime_single_mchar { \mkern2mu\Umathchar"0"0"2032\mkern-2mu~}
\cs_set:Npn \__um_prime_double_mchar { \mkern2mu\Umathchar"0"0"2033\mkern-2mu~}
\cs_set:Npn \__um_prime_triple_mchar { \mkern2mu\Umathchar"0"0"2034\mkern-2mu~}
\ExplSyntaxOff

\begin{document}

$f'(x)+f''(x)+f'''(x)$

$g'(x)+g''(x)+g'''(x)$

$h'(x)+h''(x)+h'''(x)$

\end{document}

在此輸入影像描述

相關內容