After upgrading to TeX Live 2022, I found a lot of my previous code broken due to the clash between newtx
and fontspec
. Here is a minimal example (The engine is XeLaTeX under Windows):
\documentclass[11pt]{article}
\usepackage{xeCJK}
\usepackage{newtxtext} % !!!
\usepackage{newtxmath} % !!!
\usepackage{fontspec}
\setsansfont{TeX Gyre Heros}
\setCJKmainfont{Noto Serif CJK SC}
\begin{document}
\[ x^2+y^2=z^2 \]
Test English.
测试中文。
\end{document}
The code will not compile and shows error:
! Package fontspec Error: The font "TeX Gyre Heros" cannot be found.
...
! Package fontspec Error: The font "Noto Serif CJK SC" cannot be found.
However, if I comment out the two lines with !!!
, then it compiles.
With this A/B test I know that it is the recent (official) support of unicode-engine in newtx
that breaks my code, because newtx
uses fontspec
now. I tried to pass [nofontspec]
to newtx
but the font turned out to be wrong.
What exactly is happening here? Any suggestions for fixing all my codes (I use newtx
with fontspec
heavily) without doing too much work?
newtx
. The engine is XeLaTeX under Windows.\usepackage{newtxtext}
and\setCJKmainfont{Noto Serif CJK SC}
, i.e., why are you trying to set up two rather mutually incompatible text fonts?\setCJKmainfont{Noto Serif CJK SC}
specifies the fonts for CJK characters. Even if I remove this line, the file won't compile and says TeX Gyre Heros is not found.