0

How I make the default font in math mode has nothing to do with \setmainfont{some font}.

Why is the character specified by \it Times New Roman and the others are Computer Modern?

Now I want to change \it font which in math mode to Computer Roman.

Code:

\documentclass{book}
\usepackage{fontspec}
\usepackage[T1]{fontenc}
\setmainfont{Times New Roman}
\begin{document}
${v}_v={\it v}_0$,$x={\textit v} _0t$\par

$v_x=v_0$
\end{document}

Patch Code:

\documentclass{book}
\usepackage[no-math]{fontspec}
\showoutput
\setmainfont{Times New Roman}
\RequirePackage{unicode-math}
\setmathfont{TeX Gyre Termes Math}
\setmathfont{XITSMath-Regular}
[
    Extension = .otf,
    BoldFont = XITSMath-Bold,
    range={"1D70B, "2605, "2ACB, "2AFD, "23DC}
]
\setmathfont{STIX Two Math}[range={"221A, "221B, "221C}]
\setmathfont{Times New Roman}[range={"03C0}]
\setmathfont{XITSMath-Regular}
[
Extension = .otf,
BoldFont = XITSMath-Bold,
range={"2A00-"2AFF}
]
\begin{document}

${v}_v=\mathit{v}_0$,$x=\textit{v} _0t$\par

$v_x=v_0$
\end{document}
3
  • Please add an example to clarify your question, \setmainfont{some font} does not change the main math fonts, however the [no-math] option to fontspec stops it changing math at all Commented Nov 21, 2022 at 9:50
  • @DavidCarlisle patch Commented Nov 21, 2022 at 10:21
  • 2
    (a) never use \usepackage[T1]{fontenc} with luatex (b) don't use \it with latex (although \mathit{v} would be the same (c) use [no-math] as noted above Commented Nov 21, 2022 at 10:23

1 Answer 1

2

Never use T1 encoding with lualatex or xelatex.

\documentclass{book}
\usepackage{fontspec}
\showoutput
\setmainfont{Times New Roman}
\begin{document}
${v}_v={\it v}_0$,$x={\textit v} _0t$\par

$v_x=v_0$
\end{document}

Here {v}_v use computer modern math italic

{\it v} which should be \mathit{v} uses Times Roman Italic

{\textit v} which should be \textit{v} uses Times Roman Italic

add [no-math] then all but textit use the cm math fonts.

\documentclass{book}
\usepackage[no-math]{fontspec}
\showoutput
\setmainfont{Times New Roman}
\begin{document}
${v}_v=\mathit{v}_0$,$x=\textit{v} _0t$\par

$v_x=v_0$
\end{document}

Note you are using , U+ff0c FULLWIDTH COMMA which is not in most latin fonts, use a normal ascii , similarly use = not U+ff1d FULLWIDTH EQUALS SIGN

\documentclass{book}
\usepackage[no-math]{fontspec}
\showoutput
\setmainfont{Times New Roman}
\begin{document}


${v}_v=\mathit{v}_0$, $x=\textit{v} _0t$\par

$v_x=v_0$
\end{document}

enter image description here


Your edited question shows using Stix Two mostly, but wanting to revert to Computer Modern locally. Here I set up an lm math version which is the default cm-style math font used by unicode-math but here just loaded in lm version.

\documentclass{book}
\usepackage{unicode-math}
\showoutput
\setmainfont{Times New Roman}
\setmathfont{STIX Two Math}
\setmathfont[version=lm]{Latin Modern Math}
\begin{document}


${v}_v=\mathit{v}_0$, $x=\textit{v} _0t$\par

$v_x=v_0$

{\mathversion{lm}


${v}_v=\mathit{v}_0$, $x=\textit{v} _0t$\par

$v_x=v_0$

}

\end{document}

enter image description here

11
  • I use xelatex,so can i use T1 encoding? Commented Nov 21, 2022 at 10:41
  • 1
    @Mahsatshak no xetex the advice is even stronger. T1 completely breaks xelatex hyphenation Commented Nov 21, 2022 at 10:46
  • The prologue has defined mathfont, but I want to make mathfont Computer Modern in some specific places temporarily. I added new patch in example. Commented Nov 21, 2022 at 12:34
  • @Mahsatshak how could you have expected anyone to ever have guessed that from your original question which had no code at all????? I'll add something Commented Nov 21, 2022 at 13:15
  • @Mahsatshak done Commented Nov 21, 2022 at 13:24

You must log in to answer this question.

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