7

I'm using XeLaTeX on Linux. I know that Latin Modern Roman is the default font of XeLaTeX, however if in my preamble I write

\setmainfont{Latin Modern Roman}
\setsansfont{Latin Modern Sans}
\setmonofont{Latin Modern Mono}
\setmathfont{Latin Modern Math}

I get errors like

The font "Latin Modern Roman" cannot be found \setmainfont{Latin Modern Roman}.

I really do not understand what is the name of this defaul character. Then, I use unicode-math package: my preamble is

\documentclass{article}
\usepackage{fontspec}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
%\setmainfont{Latin Modern Roman}
%\setsansfont{Latin Modern Sans}
%\setmonofont{Latin Modern Mono}
% \setmathfont{Latin Modern Math}
\usepackage{unicode-math} 

I don't like default \mathbb and \mathcal font of XeLaTeX. I noticed that, if I remove unicode-math I get the correct symbols. How to continue using unicode-math and having AMS font fot \mathbb and \mathcal?

MaPo
  • 1,163
  • Please provide a complete example we can compile. Note that fontspec enables Latin Modern for text by default. There is no need to set the serif. sans and mono as you do. I imagine that these fonts may not be installed for your system generally, which is necessary in order to use their names in this way with fontspec. – cfr May 03 '16 at 22:55

1 Answers1

6

I don't know why Latin Modern Roman is not recognized, perhaps it's not correctly installed as a system font.

For getting the “traditional” calligraphic and blackboard fonts you can use the standard setup.

\documentclass{article}
\usepackage{amsmath} % should go before unicode-math
%\usepackage{fontspec} % already loaded by unicode-math
\usepackage{unicode-math}
\usepackage{amsthm}

\setmainfont{Latin Modern Roman}
\setsansfont{Latin Modern Sans}
\setmonofont{Latin Modern Mono}
\setmathfont{Latin Modern Math}

\DeclareMathAlphabet{\mathcal}{OMS}{cmsy}{m}{n}
\let\mathbb\relax % remove the definition by unicode-math
\DeclareMathAlphabet{\mathbb}{U}{msb}{m}{n}

\begin{document}

abc \textsf{def} \texttt{ghi}

$a+b\in\mathbb{R}\setminus\mathcal{ABC}$

\end{document}

enter image description here

egreg
  • 1,121,712
  • It seems that it accets only file name (like *.otf) but not the name of the character. How can I proceed? – MaPo May 03 '16 at 23:13
  • 1
    @MaPo Actually Latin Modern is chosen by default, so you can just leave all \set...font instructions off. – egreg May 03 '16 at 23:16
  • 1
    Why if I use $\bar{\mathcal{Q}}$ I get an error message. Is there a way to get the correct result? – MaPo Jun 07 '17 at 16:22
  • @MaPo Sorry, only an ugly workaround. – egreg Jun 07 '17 at 17:22
  • Ok, so there is no way to use exactly the same fonts? – MaPo Jun 07 '17 at 17:33
  • If you accept the ugly workaround… I wouldn't be too attached to the precise shape, though. – egreg Jun 07 '17 at 17:34
  • @egreg if default fonts are not decleared expictly, macros from fontspec like \addfontfeatures seems like not to work. Anything to deal with it? – lyl May 12 '22 at 13:10
  • @lyl You cannot add features to the default font. – egreg May 12 '22 at 14:58