I'm having trouble with the way the characters are spaced in the Metropolis Beamer theme, while using the serif font for math mode. Here's a MWE:
\documentclass[10pt]{beamer}
\usetheme[progressbar = frametitle,
block = fill,
background = light
]{metropolis}
\usepackage{appendixnumberbeamer}
\usepackage{booktabs}
\usepackage[scale=2]{ccicons}
\usepackage{pgfplots}
\usepgfplotslibrary{dateplot}
\usepackage{xspace}
\newcommand{\themename}{\textbf{\textsc{metropolis}}\xspace}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{tikz-cd}
\usepackage{tikz}
\usepackage{bm}
\usepackage{mathbbol}
\usepackage{caption}
\usepackage{bbm}
\usepackage{graphicx}
\usepackage{scalerel}
\usepackage{accents}
\usepackage{soul}
\usepackage{mathtools}
\usepackage{dirtytalk}
\usepackage{shuffle}
\usepackage{tensor}
\DeclareSymbolFontAlphabet{\mathbb}{AMSb}
\DeclareSymbolFontAlphabet{\mathbbl}{bbold}
\usepackage[utf8]{inputenc}
\usefonttheme[onlymath]{serif}
\begin{document}
\begin{frame}
\[
\mathbb E[Y]
\]
\end{frame}
\end{document}
I've compiled this with XeTeX, MacTeX distribution (I had to install the fira sans font system-wide to get the theme to work). As you can see, the character spacing is way off: This seems to happen with some characters and not others, but is pervasive throughout the document, and looks quite bad.
I would be grateful for any advice for how to fix this without changing the theme or font. Perhaps there is some way of requiring the math font switch within the .sty file, in a way that results in the spacing being correct. Thank you.
inputenc
package with xetex and luatex). My advice would be to use pdftex and be happy, unless there are particular reasons for using xetex.\usefonttheme{professionalfonts}
with xetex, see e.g. tex.stackexchange.com/a/266138/82917