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.

1 Answer 1

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

2
  • 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
    Commented Apr 27, 2021 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 tex.stackexchange.com/questions/579971/… may also do the trick (although I don't know which declaration would be needed here).
    – Marijn
    Commented Apr 28, 2021 at 7:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .