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.
  1. Package fontspec Warning: OpenType feature 'VerticalPosition=ScientificInferior' (sinf) not available for font 'TeXGyreTermesX-Regular' with script 'CustomDefault' and language 'Default'.

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

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

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

  5. 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?

DGuys
  • 57
  • 4
  • 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. – samcarter_is_at_topanswers.xyz Nov 26 '23 at 20:09
  • What is that reference to colors? – José Carlos Santos Nov 26 '23 at 20:14
  • 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 '23 at 20:15
  • 1
    However, your claim that you stopped using the fontspec package can't be correct either, as otherwise you wouldn't be receiving warning and error messages related to using the fontspec package. – Mico Nov 26 '23 at 20:17
  • @JoséCarlosSantos You have to excuse me, I do not know if all the editors have this. It is something Overleaf does to so the importance of the error. – DGuys Nov 26 '23 at 20:27
  • @Mico I removed the package. Of course all of the code uses the font but I assumed that it would work with this one too. It is just a total mess, I have already written a lot, I am writing my thesis, so I do not know where the errors are... – DGuys Nov 26 '23 at 20:28
  • 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. – David Carlisle Nov 26 '23 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 '23 at 21:20
  • @Mico XeLaTeX. I am just saying that with \usepackage{fontspec} \setmainfont{Times New Roman} everything works but I want to use the other. If I delele \usepackage{fontspec} \setmainfont{Times New Roman} and write \usepackage[T1]{fontenc} \usepackage{newtxtext, newtxmath} instead, then these warnings appear and can not compile write. Obviously I have something that has to do with \usepackage{fontspec} in the file but I really do not know, It it just a mess in this point. – DGuys Nov 26 '23 at 21:47
  • 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. – David Carlisle Nov 26 '23 at 22:07

2 Answers2

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)

David Carlisle
  • 757,742
  • 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 '23 at 10:09
  • Could you please explain to me the differences between the compilers (pdfLaTeX, LaTeX, XeLaTeX, LuLaTeX, etc.)? – DGuys Nov 27 '23 at 10:10
  • this for example https://tex.stackexchange.com/a/22825/1090 @DGuys – David Carlisle Nov 27 '23 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 – David Carlisle Nov 27 '23 at 10:14
2

With XeLaTeX, just use:

\usepackage[T1]{fontenc}
\usepackage{newtx}
murray
  • 7,944
  • Did not work. I really do not know... – DGuys Nov 26 '23 at 20:26
  • @DavidCarlisle which compiler is the best? LaTeX, pdfLaTeX, XeLaTeX or LuLaTeX? – DGuys Nov 26 '23 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 '23 at 21:11
  • @DavidCarlisle: How/where should one then "revert to TU"?? – murray Nov 28 '23 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) – David Carlisle Nov 29 '23 at 00:25