7

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.

5

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

  • Thanks Alan! One thing I am still confused about, however, is that this appears to say "use sans for text, and use serif for math". What if I wanted to use different serif fonts for the two, e.g. Tahoma for text, and the usual Latin Modern Sans for math? – Bobby M. Cozart Aug 18 '13 at 21:18
  • Why is the parentheses' spacing wrong in the example output? (Maybe we should leave out \usepackage{lmodern} or change it to \usepackage{unicode-math}?) – marczellm Oct 10 '13 at 17:30
1

Another possibility is to use:

\usefonttheme{professionalfonts}

MWE:

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

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.