问题描述
升级win11之后重新安装LaTex,发现我的论文编译不过,报错是STXingkai(华文行楷)字体丢失:
Package fontspec Error: The font "STXingkai" cannot be found. \maketitle
name = STXingkai/OT, rootname = STXingkai/OT, pointsize = mktexmf: empty or non-existent rootfile!
kpathsea: Running mktexmf STXingkai/OT.mf The command name is D:\texlive\2021\bin\win32\mktexmf Cannot find STXingkai/OT.mf.
name = STXingkai/OT, rootname = STXingkai/OT, pointsize = mktexmf: empty or non-existent rootfile!
kpathsea: Running mktexmf STXingkai/OT.mf The command name is D:\texlive\2021\bin\win32\mktexmf Cannot find STXingkai/OT.mf.
name = STXingkai/OT, rootname = STXingkai/OT, pointsize = mktexmf: empty or non-existent rootfile!
...
解决方法
我看了一下电脑字体库发现win11没有自带华文字体,自己上网下载了个华文行楷,安装完还是编译不过。研究了很久最后发现只要在LaTex对应报错的字体名称后面加上后缀名.ttf就行:
% 原代码
\setCJKfamilyfont{hwxingkai}{STXingkai}
\newcommand{\hwxingkai}{\CJKfamily{hwxingkai}}
\newcommand{\xiaochuhao}{\fontsize{32pt}{\baselineskip}\selectfont}
% 修改后的代码
\setCJKfamilyfont{hwxingkai}{STXingkai.ttf}
\newcommand{\hwxingkai}{\CJKfamily{hwxingkai}}
\newcommand{\xiaochuhao}{\fontsize{32pt}{\baselineskip}\selectfont}
报错解决