[Tex/LaTex] How does fontspec actually work with the no-math attribute

fontspecxetex

I'm trying to make a beamer presentation that has different fonts for math and text. As a MWE, when I write the following:

\documentclass[english]{beamer}
\usepackage{lmodern}
\usepackage[no-math]{fontspec}
\setsansfont{Tahoma}
\begin{document}
The quick brown fox jumps over the lazy dog.
\[
F(x)=\int_{0}^{x}f(t)\, dt
\]

\end{document}

what I would expect to see is regular text in Tahoma, and the math set in latin modern. This seems to be what is implied by the documentation for fontspec. However, when I run "xelatex myfile.tex", I see that the output file has Tahoma font throughout. I have made similar attempts with mathspec and with the other commands like \setmainfont and the like, but I don't see what I'm supposed to be doing.

Best Answer

This is not an issue with fontspec but with how beamer sets up the fonts. By default, beamer makes all text sans serif, including the math text. If you want serifed math and sans serif other text, use:

\usefonttheme[onlymath]{serif}

Complete example

 % !TEX TS-program = XeLaTeX

\documentclass[english]{beamer}

\usepackage{lmodern}
\usepackage{fontspec}

\setsansfont{Tahoma}
\usefonttheme[onlymath]{serif}
\begin{document}
The quick brown fox jumps over the lazy dog.
\[
F(x)=\int_{0}^{x}f(t)\, dt
\]

\end{document}

enter image description here

Related Question