1

Hi I have the following code for generate math font as Times, but default it loads CMR because unicode-math package. Here i required unicode-math package. Please suggest how to fix this issue without removing unicode-math package.

MWE:

\documentclass{book}

\usepackage{amsmath,amsfonts,amssymb}
\usepackage{xltxtra}
\usepackage{xunicode}
\defaultfontfeatures{Ligatures=TeX}
\usepackage{unicode-math}%
\usepackage{mathspec}


\setmainfont[Mapping=tex-text, Path = ../Fonts/TimesLTStd/ ,
UprightFont= TimesLTStd-Roman.otf ,
BoldFont=TimesLTStd-Bold.otf ,
ItalicFont=TimesLTStd-Italic.otf,
BoldItalicFont=TimesLTStd-BoldItalic.otf
]
{TimesLTStd-Roman}


\begin{document}

This $\mathbf{A}_{\mathbf{A}}$ is a sample text $\text{-g}100$

\end{document} 
  • note that you should not load xltxtra these days (the packages other than fontspec that it loads are not needed in recent years) similarly you do not normally need xunicode. You should use either unicode-math or mathspec, but not both (unicode-math if your math font has an opentype math table, mathspec if you are using an opentype text font for math) – David Carlisle Mar 27 '18 at 6:45
  • Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – user36296 Oct 12 '18 at 13:14
3

With unicode-math you have to use \mathbfup instead of \mathbf (or use the mathbf=sym option when loading the font).

\documentclass{book}

\usepackage{amsmath}
\usepackage{unicode-math}

\setmainfont{TimesLTStd}[
Extension = .otf,
UprightFont = *-Roman,
ItalicFont = *-Italic,
BoldFont = *-Bold,
BoldItalicFont = *-BoldItalic,
]

% Set the fallback math font
\setmathfont{TeX Gyre Termes Math}

% Load desired ranges
\setmathfont[range={up}]{TimesLTStd-Roman.otf}
\setmathfont[range={it}]{TimesLTStd-Italic.otf}
\setmathfont[range={bfup}]{TimesLTStd-Bold.otf}
\setmathfont[range={bfit}]{TimesLTStd-BoldItalic.otf}
\setmathrm{TimesLTStd-Roman.otf}

% Apply empty range from fallback font to get correct metrics
\setmathfont[range={}]{TeX Gyre Termes Math}

\begin{document}

This $\mathbfup{A}_{\mathbfup{A}}$ is a sample text $\text{-g}100$

\end{document}

enter image description here


I recommend that you use TeX Gyre Termes Math instead of trying to use the text font for math. TeX Gyre Termes Math is a Times clone, so it should blend in nicely. (You could probably also use TeX Gyre Termes for the text font and nobody would notice that it's not TimesLTStd :))

\documentclass{book}

\usepackage{amsmath}
\usepackage{unicode-math}

\setmainfont{TimesLTStd}[
Extension = .otf,
UprightFont = *-Roman,
ItalicFont = *-Italic,
BoldFont = *-Bold,
BoldItalicFont = *-BoldItalic,
]

\setmathfont{TeX Gyre Termes Math}

\begin{document}

This $\mathbfup{A}_{\mathbfup{A}}$ is a sample text $\text{-g}100$

\end{document}

enter image description here

  • Thanks Henri. It has working fine for me. Have a great day – Rajesh Kumar Mar 27 '18 at 10:26
  • @RajeshKumar If Henri’s answer solved your problem, please consider accepting it. – Davislor Jul 21 '18 at 14:52

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.