I want to change font style in my presentation. I prefere Liberation Serif font. This is TrueType font so XeLaTeX can be used. I tried to set this font using \usepackage{fontspec} and \setmainfont{Liberation Serif}, but the font in my document isn't changed. How to solve this issue?

2 Answers 2


By default, beamer uses sans serif font, so \setmainfont will do nothing. You have to tell it that you want serif fonts:

\usefonttheme{professionalfonts} % using non standard fonts for beamer
\usefonttheme{serif} % default family is serif
\setmainfont{Liberation Serif}

  • 8
    I have a similar problem as @Pavel Morozkin, I tried this code and I get the following error: ! Fatal fontspec error: "cannot-use-pdftex"!! The fontspec package requires either XeTeX or LuaTeX.!! You must change your typesetting engine to, e.g., "xelatex" or! "lualatex"instead of "latex" or "pdflatex".!! See the fontspec documentation for further information.!! For immediate help type H <return>.!............................................... \msg_fatal:nn {fontspec} {cannot-use-pdftex}
    – Gunelle
    Commented Jun 25, 2018 at 10:02
  • I am also getting a similar error.
    – Peaceful
    Commented Jul 17, 2018 at 9:55
  • 2
    @Peaceful You need to use XeLaTeX or LuaLaTeX.
    – egreg
    Commented Jul 17, 2018 at 10:20
  • @Gunelle I suppose if you're using Overleaf, there's not a lot you can do. Commented Jul 5, 2022 at 20:06

Beamer uses sans serif font by default, so you can use \setsansfont{...} to change the font (even if the font you actually want to use has serifs...)

% !TeX TS-program = lualatex


\setsansfont{Liberation Serif}


enter image description here

  • Is there a way to modify the directive to incorporate latexmk functionality? Commented Jul 14, 2023 at 10:50
  • 1
    @xFioraMstr18 Did you try latexmk -lulatex? Commented Jul 14, 2023 at 11:44
  • That works! Thank you. Commented Jul 15, 2023 at 4:36
  • But is there also a directive % TEX TS-program = ... to do the same thing? Commented Jul 15, 2023 at 4:37
  • 1
    @xFioraMstr18 The above command is for texstudio. You should better ask a proper question to get the attention of texshop users. Commented Jul 15, 2023 at 5:15

You must log in to answer this question.

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