This is a follow up question to this.
So after some experimentation, I realized that no matter which font package I put, beamer always has a problem with the formatting the accents, whereas article doesn't.
Article code:
\documentclass[12 pt]{article}
\usepackage{amsmath}
\usepackage{mleftright}
\usepackage{sansmathaccent} %To get the bar on top aligned correctly
\usepackage{accents} %For underbar
\newcommand\munderbar[1]{%
\underaccent{\bar}{#1}} %making the underbar
%Source: https://tex.stackexchange.com/questions/163280/underbar-changing-the-style-of-font-but-bar-not-why
\renewcommand{\left}{\mleft}
\renewcommand{\right}{\mright}
\begin{document}
$$\munderbar{u}_i \leq u_i\left(t\right)\leq \bar{u}_i$$
\end{document}
Output:
Beamer code (with original font):
\documentclass[12 pt,handout,notheorems]{beamer}
\usepackage{amsmath}
\usepackage{pgfpages}
\usepackage{mleftright}
\pgfpagesuselayout{resize to}[a4paper,landscape]
\usetheme{Boadilla}
\usepackage{sansmathaccent} %To get the bar on top aligned correctly
\usepackage{accents} %For underbar
\newcommand\munderbar[1]{%
\underaccent{\bar}{#1}} %making the underbar
%Source: https://tex.stackexchange.com/questions/163280/underbar-changing-the-style-of-font-but-bar-not-why
\renewcommand{\left}{\mleft}
\renewcommand{\right}{\mright}
\begin{document}
\begin{frame}
$$\munderbar{u}_i \leq u_i\left(t\right)\leq \bar{u}_i$$
\end{frame}
\end{document}
Output:
Beamer code (with serif):
\documentclass[12 pt,handout,notheorems, serif]{beamer}
\usepackage{amsmath}
\usepackage{pgfpages}
\usepackage{mleftright}
\pgfpagesuselayout{resize to}[a4paper,landscape]
\usetheme{Boadilla}
\usepackage{sansmathaccent} %To get the bar on top aligned correctly
\usepackage{accents} %For underbar
\newcommand\munderbar[1]{%
\underaccent{\bar}{#1}} %making the underbar
%Source: https://tex.stackexchange.com/questions/163280/underbar-changing-the-style-of-font-but-bar-not-why
\renewcommand{\left}{\mleft}
\renewcommand{\right}{\mright}
\begin{document}
\begin{frame}
$$\munderbar{u}_i \leq u_i\left(t\right)\leq \bar{u}_i$$
\end{frame}
\end{document}
Output:
I also tried to update MikTeX, but as mentioned in the previous query, it had no effect on fixing the efficacy of sansmathaccent in particular. I was introduced an ad-hoc method, but I would need to do so for any letter that I use if I place an accent on it. Is there any other "general" way of tackling this problem?




\usefonttheme{professionalfonts}gives “correct” maths… – Ruixi Zhang Apr 26 '20 at 21:41