Using a TrueType font in LaTeX with XeTeX

I still prefer LaTeX for presentations. There might be more comfortable software for presentations, but LaTeX is in my eyes the way to go for scientific data. The font selection is just pretty limited. The XeTeX project can help you to get TrueType fonts into your documents and presentations.

Installing XeTeX on Debian based systems

The installation on Debian based systems is easy. Just run the following command with super user permissions.

apt-get install texlive-xetex

TrueType fonts in a simple LaTeX article

Here a small example article with the default font.

\documentclass{article}

\begin{document}
    {\Huge XeTeX}
\end{document}
LaTeX article

Installing a font via command line on Debian systems

For my example I will use my selfmade handwritten TrueType font. If your True Type font is already installed on your system, feel free to skip the following part and go to TrueType font example with XeTeX. If xelatex is not able to find the font, you will get the following error message afterwards.

Your system may has more directories for fonts. You can install a true type font via command line on Debian based systems in your local font directory.

cp mrpoopybutthole.ttf ~/.local/share/fonts/.

Or an other example would be the /usr/share/fonts directory. I would prefer to put it a subdirectory. Pleas make sure to execute here with super user permissions.

cp mrpoopybutthole.ttf /usr/share/fonts/.

Double check with Gnome Font Viewer

If you are running your system with Gnome you can double check the instllation of the font with the Gnome Font Viewer.

Gnome Font Viewer

TrueType font example with XeTeX

Mostly the same example article from above with a TrueType font.

\documentclass{article}

\usepackage{xltxtra}

\setromanfont{MrPoopybutthole}

\begin{document}
    {\Huge XeTeX}
\end{document}

Please make sure to execute the program xelatex instead of pdflatex or you will get the following error message.

And the result is the same article document with an other font.

LaTeX article TrueType font

TrueType fonts in LaTeX beamer

The command \setromanfont is not working for beamer. You will need to use the command \setbeamerfont to set the font on elements. For example the title page.

\documentclass{beamer}

\usepackage{xltxtra}

\setbeamerfont{title page}{family=\fontspec{MrPoopybutthole}}

\title{XeTeX}

\begin{document}
    \frame{\titlepage}
\end{document}

The result is a LaTeX beamer presentation with a TrueType font on the title page.

LaTeX beamer TrueType font
Next Previous