Is it somehow possible to use the newtxtext and newtxmath fonts, and corresponding .sty files — as-is or modified (and if the latter, how) — with XeLaTeX instead of pdfLaTeX?

I note that:

  • newtxtext uses TeXGyre Termes primarily, but also TeXGyre Heros for sans serif, and possibly some other fonts; and
  • newtxmath uses the math fonts from txmath with many metric adjustments and other modifications
  • 2
    newtxmath should be okay, newtxtext would more or less work but it is not recommended - the font encoding is wrong. Use fontspec and setup the text fonts with open type fonts. – Ulrike Fischer Jul 4 '20 at 19:13
  • why don't you want to use the TeX Gyre fonts rather than the 8bit derivative ones? – David Carlisle Jul 4 '20 at 20:41
  • What would be the reason to use XeLaTeX? – egreg Jul 4 '20 at 21:01
  • Try using the libertinus-otf package which will set up the Libertinus fonts, a Times like fonts, for text and math. The only thing I really miss in using xelatex is the beautiful look of the complete use of the microtype package. – Herb Schulz Jul 5 '20 at 17:51
  • @egreg: My purpose in using XeLaTeX, along with unicode text fonts and unicode math fonts, would be to facilitate producing a .pdf that will validate against PDF A/2-u standards. Such validation is a real pain with pdfLaTeX and fonts that are not all unicode. – murray Jul 5 '20 at 21:17

Yes, you can write \usepackage{newtxtext, newtxmath} and compile with XeLaTeX. You might get an obscure bug related to Greek letters in \mathrm. (ETA: Commenters bring up more bugs with hyphenation patterns and non-ASCII characters than I was aware of.)

You can also use the font TeX Gyre Termes Math in unicode-math, which has a very similar appearance to newtxmath, but all the modern features and a larger selection of glyphs. There is also a text font, TeX Gyre Termes X, specifically based on the tweaks to Times in txfonts. Or you could go halfway, using an OpenType version of Times with fontspec along with math from newtxmath.

Also note that new development of TeX is currently focused on LuaTeX. There are a few packages that still only work in XeTeX, but of the features I need, HarfBuzz font rendering was finally added to LuaTeX this year, ucharclasses doesn’t work, and I prefer unicode-math to mathspec. There are still a few miscellaneous packages I might need XeTeX for here and there, but I’ve been using LuaTeX when I can for years, due to its better support for microtype.

A Pragmatic Solution

Since it’s better to use Unicode fonts in Unicode engines, use iftex to detect what kind of system you’re compiling on, if you must support both.

   \defaultfontfeatures{ Scale=MatchLowercase, Ligatures=TeX }
   \setmainfont{TeX Gyre Termes}[Scale=1.0]
   \setmathfont{TeX Gyre Termes Math}
   \usepackage{amsmath, newtxtext, newtxmath}

There should be very few incompatibilities. One that I’ve seen is capital Greek letters such as Δ within \mathrm, which happen to work in newtxmath. In unicode-math, you would use \symup\Delta or \upDelta instead.

If you want newtxmath instead of unicode-math for some reason, alternatives are to load fontspec with newtxmath and TeX Gyre Termes as the main font, mathastext, and mathspec, which also gives you letters from an OpenType font in math mode. If it’s important that the XeTeX/LuaTeX output be as identical to the PDFTeX output as possible, use TeX Gyre Termes X as the main font.

  • hyphenation will be wrong if you use 8bit fonts in xelatex (unless your hyphenation patterns don't use any non ascii letters) – David Carlisle Jul 5 '20 at 10:40
  • @DavidCarlisle Albeit, in that case, you aren’t using newtxtext, but some other font such as tempora? – Davislor Jul 5 '20 at 12:11
  • Sorry I don't understand your reply? I mean that your first sentence implies that you can do this in xelatex \documentclass{article} \usepackage{newtxtext, newtxmath} \begin{document} abc \end{document} you will get no error but no hyphenation patterns are loaded for 8bit fonts so hyphenation if it works will just be accidental mis-interpretation of the utf8 patterns. – David Carlisle Jul 5 '20 at 13:07
  • 1
    Running \documentclass{article} \usepackage{newtxtext, newtxmath} \begin{document} Grüße \end{document} with XeLaTeX results in "GrüSSe" instead of "Grüße" as expected, so 8bit fonts in Unicode engines are not only dangerous because of hyphenation patterns. (Same with LuaLaTeX.) – moewe Jul 5 '20 at 20:49
  • Re using \iftex: I can compile in either pdfLaTeX or XeLaTeX (or LuaLaTeX). Which I use will be determined by what choice I make in text and math fonts — whether they are completely (or nearly completely) unicode-based. – murray Jul 5 '20 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.