24/01/2017

LuaLaTeX, TeXlive, beamer and multimedia

 


Sometimes you need beamer to be a bit more, er, powerpointy. E.g., use a TTF font, have a more or less blank page and cram some text, images and movies on there. LuaLaTeX to the rescue. I installed texlive-xetex and texlive-luatex, got myself a minimal beamer template, started to dump objects into tikzpictures and compiled with lualatex instead of pdflatex. Sadly, what worked fine on TeXLive 2012 at work failed at home with a lot of nasty PDF specific error messages due to some bug in TeXLive 2016. Apparently, to get beamer, multimedia and LuaLaTeX to play nicely together, you need to add a \RequirePackage{luatex85} as the first line in your document. So here's a minimal example in very bad taste.

%\RequirePackage{luatex85} %uncomment for texlive 2016
\documentclass[gray]{beamer}
\usepackage[english]{babel}
\usepackage{fontspec}
\setsansfont[Path = fonts/,
    Extension = .ttf,
    Ligatures = TeX,
    BoldFont = comicbd ]
{comic}%use \setmainfont for non-beamer
\usepackage{amsmath}
\usepackage{multimedia}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}{}
\setbeamertemplate{itemize items}[circle]
\begin{document}
\begin{frame}[plain]
\frametitle{Science is fun!}
\begin{columns} \begin{column}{.5\textwidth}
\begin{itemize} \item random equation! \end{itemize}
\begin{align*} \rho\left(\frac{\partial}{\partial t}+\vec{u}\cdot\vec{\nabla}\right)\vec{u} &= -\vec{\nabla} p + \eta \nabla^2\vec{u}\\
\vec{\nabla}\cdot\vec{u} &=0 \end{align*}
\end{column} \begin{column}{.5\textwidth} \movie{\includegraphics[width=\textwidth]{movieposter}}{demomovie.avi} \begin{itemize} \item random animation! \end{itemize}
\end{column} \end{columns}
\end{frame}
\end{document}
Notes: I kept the TTF fonts in a subfolder 'fonts' next to the .tex source file. Font names correspond to the ttf file names without extensions (i.e. comic.ttf, comicbd.ttf). LuaLaTeX also works with system fonts, but then you're at the mercy of your font manager. In that case, just \setsansfont{comic} should work as well.
Beamer's default font style is sans serif. For serif font styles, use \setmainfont instead.