\usepackage{iftex} \ifPDFTeX \usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc} \usepackage[utf8]{inputenc} \usepackage{textcomp} % provide euro and other symbols \else % if luatex or xetex $if(mathspec)$ \ifXeTeX \usepackage{mathspec} % this also loads fontspec \else \usepackage{unicode-math} % this also loads fontspec \fi $else$ \usepackage{unicode-math} % this also loads fontspec $endif$ \defaultfontfeatures{Scale=MatchLowercase}$-- must come before Beamer theme \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1} \fi $if(fontfamily)$ $else$ $-- Set default font before Beamer theme so the theme can override it \usepackage{lmodern} $endif$