44

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

53

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

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

\begin{document}
\begin{frame}
Abdce
\end{frame}
\end{document}
4
  • 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
    Jun 25, 2018 at 10:02
  • I am also getting a similar error.
    – Peaceful
    Jul 17, 2018 at 9:55
  • 2
    @Peaceful You need to use XeLaTeX or LuaLaTeX.
    – egreg
    Jul 17, 2018 at 10:20
  • @Gunelle I suppose if you're using Overleaf, there's not a lot you can do. Jul 5, 2022 at 20:06
1

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

\documentclass{beamer}

\usepackage{fontspec}
\setsansfont{Liberation Serif}

\begin{document}
    
\begin{frame}
    abc
\end{frame} 
    
\end{document}

enter image description here

8
  • Is there a way to modify the directive to incorporate latexmk functionality? Jul 14, 2023 at 10:50
  • 1
    @xFioraMstr18 Did you try latexmk -lulatex? Jul 14, 2023 at 11:44
  • That works! Thank you. Jul 15, 2023 at 4:36
  • But is there also a directive % TEX TS-program = ... to do the same thing? 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. 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 .