ElegantLaTeX/ElegantBook

单独使用 `newtxmath` 设置数学字体的时候, `\sin` 等正体符号无法使用正文字体.

syvshc opened this issue · 6 comments

mwe 为

\documentclass{article}
\usepackage{fontspec}
\setmainfont{texgyretermes-regular.otf}
\usepackage[]{newtxmath}
\begin{document}
$ \sin x $ 
\end{document}
% 用 xelatex 编译
\documentclass[cn, math=newtx]{elegantbook}
\begin{document}
$ \sin x $ 
\end{document}

image

会发现 \sin 的字体并不是正文配置的 TG Termes, 正在查找原因及解决方法, 如果无法通过 newtxmath 解决, 需要考虑替换为 unicode-math 实现.

otf 西文字体搭配 type1 数学字体处理起来比较麻烦,可以参考 SJTUThesis/latex/sjtuthesis/fd/sjtu-math-font-termes.def#L52-L65,这个可以正确配置 \mathrm 的字体。

不过这是 newtx v1.7 前的配置,不确定更新后会不会有问题。

otf 西文字体搭配 type1 数学字体处理起来比较麻烦,可以参考 SJTUThesis/latex/sjtuthesis/fd/sjtu-math-font-termes.def#L52-L65,这个可以正确配置 \mathrm 的字体。

测试后没有问题, 我猜原理是让 \mathrm 去用 newtxmath 中的直立字体?

\documentclass{article}
\usepackage[]{fontspec}
\setmainfont{texgyreheros-regular.otf}
\let\oldencodingdefault\encodingdefault
\let\oldrmdefault\rmdefault
\let\oldsfdefault\sfdefault
\let\oldttdefault\ttdefault
\usepackage[T1]{fontenc}
\renewcommand{\rmdefault}{ntxtlf}
\renewcommand{\sfdefault}{qhv}
\renewcommand{\ttdefault}{ntxtt}
\usepackage[upint]{newtxmath}
\let\encodingdefault\oldencodingdefault
\let\rmdefault\oldrmdefault
\let\sfdefault\oldsfdefault
\let\ttdefault\oldttdefault
\begin{document}
sin x, $ \sin x $ 
\end{document}

image

测试后没有问题, 我猜原理是让 \mathrm 去用 newtxmath 中的直立字体?

不是,ntxtlf, qhvntxtt 都是 type1 西文字体。我的理解是,载入 newtxmath 时会保存下 \encodingdefault\rmdefault 用于 \mathrm 的字体。

不过,最理想的方案还是把 newtxmath 转成 otf math 字体,毕竟很多人还是更喜欢 newtxmath 的字形。

不过,最理想的方案还是把 newtxmath 转成 otf math 字体。

我理解了, 谢谢您

https://tex.stackexchange.com/a/642789/180617 我在 tex.se 上获得了一个回答, 似乎可以实现