2

A noob is again in need.

I was told to use \usepackage{newtxtext, newtxmath} instead of \setmainfont{Times New Roman} (I assume I will still have the font in Times New Roman. Also, use \usepackage[T1]{fontenc} instead of \usepackage{fontspec}.

So, if I use:

    \usepackage{fontspec}
    \setmainfont{Times New Roman}

everything is fine.

But, If I use:

    \usepackage[T1]{fontenc}
    \usepackage{newtxtext, newtxmath}

instead of the above, it produces 6 errors (1 in red and 5 in orange). I will include them below:

1) (RED) LaTeX Error: Command `\Bbbk' already defined.

2) Package fontspec Warning: OpenType feature 'VerticalPosition=ScientificInferior' (sinf) not available for font 'TeXGyreTermesX-Regular' with script 'CustomDefault' and language 'Default'.

3) Package fontspec Warning: OpenType feature 'VerticalPosition=ScientificInferior' (sinf) not available for font 'TeXGyreTermesX-Italic' with script 'CustomDefault' and language 'Default'.

4) Package fontspec Warning: OpenType feature 'VerticalPosition=ScientificInferior' (sinf) not available for font 'TeXGyreTermesX-Slanted' with script 'CustomDefault' and language 'Default'.

5) Package fontspec Warning: OpenType feature 'VerticalPosition=ScientificInferior' (sinf) not available for font 'TeXGyreTermesX-BoldItalic' with script 'CustomDefault' and language 'Default'.

6) Package fontspec Warning: OpenType feature 'VerticalPosition=ScientificInferior' (sinf) not available for font 'TeXGyreTermesX-BoldSlanted' with script 'CustomDefault' and language 'Default'.

What are the differences between these 2, which should I use and how do I get rid of the errors?

10
  • 4
    Please don't show just a code fragment, always include a small, but compilable test file. The problem seems to be the interaction with other packages in your code. Nov 26, 2023 at 20:09
  • 1
    "I was told to use..." Who told you this? It can't be correct in general, and it certainly betrays the ignorance of whoever told you to do this.
    – Mico
    Nov 26, 2023 at 20:15
  • 3
    the errors you show are clearly not from the code that you show so it is hard to help, if you replace fontspec by fontenc then clearly you will not get warnings from the fontspec package. Nov 26, 2023 at 20:42
  • 3
    Please provide more information about what you actually do. E.g., do you employ pdfLaTeX, XeLaTeX, or LuaLaTeX to compile your document?
    – Mico
    Nov 26, 2023 at 21:20
  • 3
    if you remove fonspec then you can not get fontspec errors in the log. You are not providing any usable information to allow anyone to help. If you make the change you say you make, changing fontspec to [T1]{fontenc} and newtx then use pdflatex (which is the default at overleaf) not xelatex. Nov 26, 2023 at 22:07

2 Answers 2

7

You provided no usable code but

\documentclass{article}

\usepackage{fontspec}
\setmainfont{Times New Roman}

\begin{document}

abc
\end{document}

will work on Overleaf with xelatex (or lualatex) and use the Microsoft "Times New Roman" font.

This is easier to see with lualatex than xelatex as the log shows the fonts used with lualatex (as it does with pdflatex)

/usr/share/fonts/truetype/msttcorefonts/times.ttf

If you change that to

\documentclass{article}
\usepackage{newtxtext,newtxmath}

\begin{document}

abc
\end{document}

Then with xelatex or lualatex you will use the "TeX Gyre Termes" free clone of Times Roman, as shown in the lualatex log

/usr/local/texlive/2023/texmf-dist/fonts/opentype/public/newtx/TeXGyreTermesX-Regular.otf

This is still an OpenType (Unicode) font.

If you change this to use the legacy 8bit T1 encoding for western European Latin scripts.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{newtxtext,newtxmath}

\begin{document}

abc
\end{document}

Then you should use the 8-bit pdflatex compiler not the Unicode xelatex or lualatex.

In this case the pdflatex log will show the font as

/usr/local/texlive/2023/texmf-dist/fonts/type1/public/newtx/ztmr.pfb

which is a type1 (8 bit PostScript) font built specifically for pdflatex newtx package, and derived originally from the TeX Gyre Termes font used above.

Naturally you can only do this if your script is in the subset covered by T1 (so not Greek or Cyrillic for example which would be in the Unicode font but not in the T1 encoded subset)

4
  • Thank you very much! I am using Greek language too and the compiler is XeLaTeX, so I should not use the T1, very useful!
    – DGuys
    Nov 27, 2023 at 10:09
  • Could you please explain to me the differences between the compilers (pdfLaTeX, LaTeX, XeLaTeX, LuLaTeX, etc.)?
    – DGuys
    Nov 27, 2023 at 10:10
  • this for example tex.stackexchange.com/a/22825/1090 @DGuys Nov 27, 2023 at 10:12
  • @DGuys I would probably use lualatex in preference to xelatex if you want Unicode. For 8 bit tex you want LGR encoding for greek, so \usepackage[LGR,T1]{fontenc} if you use pdflatex Nov 27, 2023 at 10:14
2

With XeLaTeX, just use:

\usepackage[T1]{fontenc}
\usepackage{newtx}
5
  • Did not work. I really do not know...
    – DGuys
    Nov 26, 2023 at 20:26
  • @DavidCarlisle which compiler is the best? LaTeX, pdfLaTeX, XeLaTeX or LuLaTeX?
    – DGuys
    Nov 26, 2023 at 21:43
  • @DavidCarlisle: I was just following what's shown for xelatex in newtxdoc.pdf, pages 6-7. What exactly is the problem with encoding here? (Especially if one loads babel and has to use T2A encoding, too, say, for russian?)
    – murray
    Nov 27, 2023 at 21:11
  • @DavidCarlisle: How/where should one then "revert to TU"??
    – murray
    Nov 28, 2023 at 22:35
  • 1
    Note in general T1 should not be used for xelatex (it's a legacy 8 bit encoding and hyphenaion is not set up) newtx package detects xetex and reverts to the default TU (Unicode) encoding so it's simpler and safer to omit the fontenc line for xetex (or luatex) Nov 29, 2023 at 0:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .