0

I have the following document:

\documentclass{beamer}
\usepackage{sansmathfonts}

\begin{document} \begin{frame}{} Test $ a\sigma $ \end{frame} \end{document}

If I compile it with PDFLaTeX, I get the expected result:

enter image description here

However, with XeLaTeX I get the following strange result:

enter image description here

If I remove the line \usepackage{sansmathfonts} I get what you'd expect, both with PDFLaTeX and XeLaTeX:

enter image description here

(note the "serif" σ).

I've tried explicitly telling beamer to use the sans font, but that didn't change anything. Also, the problem persists if I use article and set \renewcommand{\familydefault}{\sfdefault}, so I don't think this has anything to do with beamer.

saarl
  • 129

1 Answers1

1

Packages such as sansmathfonts are usually not designed with the font loading mechanisms of XeLaTeX in mind. While it might work generally, some unexpected problems are, well, expected, as you have found out.

In such situations using the normal approach for fonts in XeLaTeX generally works better, i.e., loading a system-installed font using fontspec.

For math specifically there is the mathspec package that works on top of fontspec and allows to specify the math font in some detail.

Of course you need to find a font that has all the required font shapes, i.e., latin, greek, italic, in sans-serif.

Example with Liberation Sans as font:

\documentclass{beamer}
\usepackage{mathspec}
\setmainfont{Liberation Sans}
\setmathfont(Digits,Latin,Greek){Liberation Sans}

\begin{document} \begin{frame}{Test of Liberation Sans} Test $ a\int_\infty \sqrt{\sigma\alpha\beta\pi} $ \end{frame} \end{document}

enter image description here

Marijn
  • 37,699
  • I really like the fonts provided by sansmathfonts. Am I right in assuming it wouldn't be feasible (or maybe legal?) convert those fonts to system fonts? – saarl Apr 27 '21 at 17:00
  • 1
    @saarl It is feasible, using FontForge for example, and it is also legal because the package is licensed under the LPPL. But it would not be easy :) you could try contacting the package author to see if she can think of a solution. Something similar to the comment https://tex.stackexchange.com/questions/579971/xetex-beamer-math-accent#comment1459233_579971 may also do the trick (although I don't know which declaration would be needed here). – Marijn Apr 28 '21 at 07:04