# Beamer: Use Libertine and Computer Modern monospace (pdflatex vs lualatex)

I am using beamer to write a presentation. I included the libertine package to change the default font, and I am using the professionalfonts theme to avoid clashes with beamer's font settings.

I however dislike Libertine's monospaced family so I would like to revert to Computer Modern for \tt text. Therefore I included \renewcommand{\ttdefault}{cmtt} in my preamble.

The problem is that using pdflatex I get the desired effect while this breaks using lualatex. Can anybody tell me what's going wrong and how I can fix it?

Here's a MWE

\documentclass{beamer}
\usefonttheme{professionalfonts}

\usepackage[T1]{fontenc}
\usepackage{libertine}

\renewcommand{\ttdefault}{cmtt}

\begin{document}

\begin{frame}
\begin{center}
\Huge\sc
Thanks!

{\Large\tt http://www.nice.website}
\end{center}
\end{frame}

\end{document}


With lualatex:

With pdflatex:

-
I found a workaround by adding the tt=false option of libertine I can make it work with lualatex but I still not understand what's wrong. –  Bordaigorl Aug 22 '14 at 14:01

As noted by Seb, the fontspec package is often used for handling (OpenType) fonts in LuaLaTeX. However, loading the package is not mandatory (but there are benefits to using OpenType fonts).

According to the libertine manual, there is a package option type1 (or nofontspec) for reverting to Type 1 fonts, as used by pdflatex. The option is relevant when compiling with lualatex or xelatex. It will do nothing with pdflatex.

The modified document (the same fonts for lualatex and pdflatex):

\documentclass{beamer}
\usefonttheme{professionalfonts}
\usepackage[T1]{fontenc}
\usepackage[type1]{libertine}
\renewcommand{\ttdefault}{cmtt}
\begin{document}
\begin{frame}
\begin{center}
\Huge\sc
Thanks!

{\Large\tt http://www.nice.website}
\end{center}
\end{frame}
\end{document}


Without the type1 option, libertine will automatically load fontspec when Lua(La)TeX or Xe(La)TeX is used. As a result, the font encoding will be EU2 or EU1, respectively. When the MWE is compiled with lualatex (xelatex), there is a warning that the font cmtt is not available in the EU2 (EU1) encoding, and a substitute font is used instead.

-
This is exactly what I wanted to know! Thanks a lot! –  Bordaigorl Aug 23 '14 at 23:00

This is because LuaLaTeX handles fonts in a different way.
The equivalents to your working PDFLaTeX options are

\usepackage{fontspec} % Font handling
\setmainfont[]{Linux Libertine O} % Main font is Linux Libertine
\setmonofont[]{CMU Typewriter Text} % Monospace font is Computer Modern Typewriter


For deeper understanding of what is going on with fonts in LuaLaTeX you may have a look at the Fontspec package documentation.

-
Thanks. Is there a solution that can work for both engines? I mean, this would make it work for lualatex only while I was hoping to get something that compiles unchanged with both engines (avoiding \ifluatex nonsense) –  Bordaigorl Aug 22 '14 at 14:10
Specifically: is \ttdefault just ignored by luatex? –  Bordaigorl Aug 22 '14 at 14:11
Your "workaround" (tt=false option) is the way to get it working for both traditional and emerging engines. –  user51830 Aug 22 '14 at 15:45