# How to correctly use newtxtext and newtxmath with luatex

I know I must be doing something silly here, but I do not know what.

\documentclass[12pt]{article}%
\usepackage{amsmath}
\usepackage{fontspec}
\usepackage{newtxtext,newtxmath}

\begin{document}

This is my equation
$\mathbf{\dot{x}}=A x \mathbf{x}$

\end{document}


When compiled with lualatex foo.tex the math is missing the dot over the x.

>lualatex foo2.tex
This is LuaTeX, Version 1.10.0 (TeX Live 2019)
restricted system commands enabled.
(./foo2.tex
LaTeX2e <2018-12-01>

luaotfload | main : initialization completed in 0.184 seconds
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/size12.clo))
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the ?' option.
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/expl3-code.tex
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/l3deprecation.def))
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3backend/l3backend-pdfmode.def))
) (/usr/local/texlive/2019/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/tuenc.def))
(/usr/local/texlive/2019/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/usr/local/texlive/2019/texmf-dist/tex/latex/newtx/newtxtext.sty
newtxtext' v1.531, 2018/03/27 Text macros taking advantage of TeX-Gyre Termes
fonts (msharpe)
(/usr/local/texlive/2019/texmf-dist/tex/latex/fontaxes/fontaxes.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/xkeyval/xkvutils.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/xkeyval/keyval.tex))))
(/usr/local/texlive/2019/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/t1enc.def)
(/usr/local/texlive/2019/texmf-dist/tex/latex/lm/t1lmr.fd))
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/textcomp.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/ts1enc.def)))
(/usr/local/texlive/2019/texmf-dist/tex/latex/newtx/newtxmath.sty
newtxmath' v1.601, 2019/10/02 Math macros based originally on txfonts (msharpe
) (/usr/local/texlive/2019/texmf-dist/tex/latex/trimspaces/trimspaces.sty)
(/usr/local/texlive/2019/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/ifluatex.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/oberdiek/centernot.sty)
(/usr/local/texlive/2019/texmf-dist/tex/generic/kastrup/binhex.tex))
(/usr/local/texlive/2019/texmf-dist/tex/latex/newtx/t1ntxtlf.fd) (./foo2.aux)
(/usr/local/texlive/2019/texmf-dist/tex/latex/newtx/omlntxmi.fd)
(/usr/local/texlive/2019/texmf-dist/tex/latex/newtx/untxexa.fd)
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/ts1cmr.fd)
(/usr/local/texlive/2019/texmf-dist/tex/latex/newtx/lmsntxsy.fd)
(/usr/local/texlive/2019/texmf-dist/tex/latex/newtx/lmxntxexx.fd)
(/usr/local/texlive/2019/texmf-dist/tex/latex/newtx/ot1ntxtlf.fd)
(/usr/local/texlive/2019/texmf-dist/tex/latex/newtx/untxmia.fd)
(/usr/local/texlive/2019/texmf-dist/tex/latex/newtx/untxsym.fd)
(/usr/local/texlive/2019/texmf-dist/tex/latex/newtx/untxsyc.fd) [1{/usr/local/t
exlive/2019/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (./foo2.aux))
(see the transcript file for additional information)
497 words of node memory still in use:
6 hlist, 2 vlist, 2 rule, 2 glue, 4 kern, 2 sub_mlist, 1 glyph, 9 attribute,
51 glue_spec, 9 attribute_list, 1 write nodes
avail lists: 2:23,3:7,4:3,5:25,6:1,7:43,8:6,9:7,11:1
{/usr/local/texlive/2019/texmf-dist/fonts/enc/dvips/newtx/ntx-ot1-tlf.enc}{/usr
/local/texlive/2019/texmf-dist/fonts/enc/dvips/newtx/ntx-ec-tlf.enc}</usr/local
/texlive/2019/texmf-dist/fonts/type1/public/newtx/NewTXMI.pfb></usr/local/texli
ve/2019/texmf-dist/fonts/type1/public/tex-gyre/qtmb.pfb></usr/local/texlive/201
9/texmf-dist/fonts/type1/public/tex-gyre/qtmr.pfb></usr/local/texlive/2019/texm
f-dist/fonts/type1/public/newtx/txmiaX.pfb>
Output written on foo2.pdf (1 page, 34331 bytes).
Transcript written on foo2.log.
(base) >


Gives

But it should be like this:

\documentclass[12pt]{article}%
\usepackage{amsmath}
\begin{document}

This is my equation
$\mathbf{\dot{x}}=A x \mathbf{x}$

\end{document}


TL 2019

• dont use newtxtext with luatex that is an 8bit Times clone, for classic tex, use fontspec and TeX Gyre Termes – David Carlisle Nov 9 '19 at 9:08
• @DavidCarlisle thank you. Is there a MWE to help me see how it is done? I get lost with all the different font naming and configurations needed. – Nasser Nov 9 '19 at 9:11
• What does "TL 2019" mean? – Peter Mortensen Nov 9 '19 at 21:30
• @PeterMortensen TL is short hand for TeXLive – Nasser Nov 10 '19 at 1:59

It is better to use OTF fonts with luatex, perhaps:

\documentclass[12pt]{article}%
\usepackage{amsmath}
\usepackage{unicode-math}
\setmainfont{TeX Gyre Termes}
\setmathfont{TeX Gyre Termes Math}
\begin{document}

This is my equation
$\mathbf{\dot{x}}=A x \mathbf{x}$

although perhaps better
$\dot{\symbf{x}}=A x \symbf{x}$

or
$\dot{\symbfit{x}}=A x \symbfit{x}$
\end{document}

• Which sans-serif/typewriter typeface do you think matches TeX Gyre Termes'? I find sans-serif and typewriter typefaces of Latin Modern do no match. Could you give some advice? – Eli4ph Oct 28 '20 at 12:06
• @Eli4ph for math use TeX Gyre Termes Math contains sans serif and monospace alphabets within the font, so I'd use those. ie just \symbsf{abc} with no additional font required. – David Carlisle Oct 28 '20 at 12:47
• Wow! I don't know that. As for \texttt and \textsf, what font do you think match TeX Gyre Termes? Is it a good idea to use TeX Gyre Termes Math' as the sans-serif/typewriter typeface? – Eli4ph Oct 28 '20 at 12:52
• @Eli4ph sorry the site doesn't really support asking multiple new questions as comments on old answers. Font choice isn't really on topic (but don't use the math fonts for text they don't have kerning and ligatures expected in extended text) – David Carlisle Oct 28 '20 at 12:57

The package newtxtext won't work along with fontspec.

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{fontspec}
\usepackage{newtxmath}

\setmainfont{Tempora} % or whatever Times clone you prefer

\begin{document}

This is my equation
$\dot{\mathbf{x}}=A x \mathbf{x}$

\end{document}


Note that also the pdflatex code

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{newtxtext,newtxmath}

\begin{document}

This is my equation
$\mathbf{\dot{x}}=A x \mathbf{x}$

\end{document}


would fail to produce the dot. Whether this is a bug of newtxmath is disputable. I believe that the correct syntax is

\dot{\mathbf{x}}


Although I agree with David Carlisle completely, the literal answer to the question you asked—how to use the newtxtext and newtxmath packages specifically—is this:

\documentclass[12pt]{article}%
\usepackage{amsmath}
\usepackage{newtxtext,newtxmath}
\usepackage[no-math]{fontspec}

\setmainfont{TeX Gyre Termes}[NFSSFamily = ntxtlf]

\begin{document}

This is my equation:
$\dot{\mathbf{x}} = A x \mathbf{x} = \boldsymbol{\dot{\mathrm{x}}}$

\end{document}


You should never do that, but you might realistically want to use fontspec with a legacy math package, and drop only newtxtext. If you really, truly, need to mix Unicode with legacy text encodings, the package for that is luainputenc. You might run into problems with things like capital Greek letters, which many legacy math packages load from the OT1 encoding.

For practical real-world use, you’re better off switching to unicode-math`.