無法在 lualatex 中載入 xits-math.otf 檔案;缺少 \endcsname 插入

無法在 lualatex 中載入 xits-math.otf 檔案;缺少 \endcsname 插入

這是我正在談論的問題的 MWE。我正在使用 lualatex 指令。

\documentclass{article}
\usepackage{fontspec}
\usepackage{unicode-math}

\begin{document}
\setmathfont[Path=~/texmf,
             Extension=.otf,
            ]{xits-math}


\end{document}

我得到以下輸出:

*************************************************
* fontspec warning: "script-not-exist"
* 
* Font 'xits-math' does not contain script 'Math'.
*************************************************

*************************************************
* fontspec warning: "icu-feature-not-exist-in-font"
* 
* OpenType feature 'Style=MathScript' (+ssty) not available for font
* 'xits-math' with script 'Math' and language 'Default'.
*************************************************

*************************************************
* fontspec warning: "icu-feature-not-exist-in-font"
* 
* OpenType feature 'Style=MathScriptScript' (+ssty) not available for font
* 'xits-math' with script 'Math' and language 'Default'.
*************************************************
! Missing \endcsname inserted.
<to be read again> 
\protect 
l.8             ]{xits-math}

我正在使用 XITS github 中的文件。我正在嘗試使用這種字體,因為 Latin Modern Math 沒有我想要的字符,而 XITS Math 有,但我完全無法弄清楚如何成功加載該字體。

答案1

我不確定為什麼你必須使用 的私人副本xits-math.otf,因為它是隨 TeX Live 一起分發的。

無論如何,你需要\string~

\documentclass{article}
\usepackage{fontspec}
\usepackage{unicode-math}

\setmathfont[
  Path=\string~/texmf/,
  Extension=.otf,
]{xits-math}

\begin{document}

$a+b=c$

\end{document}

我在終端機和日誌檔案中得到,

</Users/MASKED/texmf/xits-math.otf>

相關內容