# Problem using \alert{} in Beamer title with metropolis theme

I'm trying to emphasize some words in the title of a beamer document. Ex :

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usetheme{Warsaw}%\usetheme{m}%-->problem

\usepackage{tikz}
\usetikzlibrary{arrows,shapes}

\author{}

\begin{document}

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

\end{document}


Which gives the following result :

But I want to use a theme for the document ( metropolis : see https://github.com/matze/mtheme ). The problem is that errors appear during compilation while using this theme instead of Warsaw theme. The error message is :

"! Undefined control sequence.
\beamer@sort #1#2->\long \def \beamer@todo
{#1}\def \beamer@ospec {}\beamer@...
l.12 \end{frame}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., \hobx'), type I' and the correct
spelling (e.g., I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Argument of \beamerx@\alert has an extra }.
<inserted text>
..."


Is there a way to emphasize some part of the title using this theme (with \alert{} or \textbf or other environment) ?

• Try with: \title{Hello \protect\alert{World}!} – Ignasi Oct 8 '15 at 10:12
• Indeed, it solves the problem for the example I gave. But the problem remains when using some library of the package tikz. I've updated the minimal working example with the problematic lines, i.e : \usepackage{tikz} \usetikzlibrary{arrows,shapes} – Hugo Oct 8 '15 at 11:14
• move \title after \begin{document} and before \maketitle. – Ignasi Oct 8 '15 at 15:45
• @Ignasi You should make those comments into an answer. – Andrew Swann Apr 19 '16 at 7:46
• Some other comments: Your code doesn't work here with Warsaw either. The metropolis theme is now on CTAN and part of TeX Live. It has also been renamed, so that one should use \usetheme{metropolis}. – Torbjørn T. Apr 19 '16 at 10:58

If \title is defined after \begin{document} but before \maketitle, the problem is solved.

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usetheme{m}%\usetheme{m}%-->problem

\usepackage{tikz}
\usetikzlibrary{arrows,shapes}

\begin{document}
\author{}

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

\end{document}


Similar solution can be applied with other themes when TiKZ is used.

• May I ask why this solves the problem? I don't really understand why that makes the difference. – hbaderts Apr 19 '16 at 9:18
• @hbaderts, it seems counterintuitive (why should \title work differently in the preamble?), but in fact it eliminates the error. Did you try to compile the example? Anyways, I added another answer that circumvents the problem in differently. – Ruben Apr 19 '16 at 9:28

You can also use \texorpdfstring from hyperref as the problem is (generally speaking) based on the use of formatting commands while harvesting the meta data. That way you prevent that \alert gets ever in touch with pdf-specific procedures. The compiler usually don't likes to see anything but plain text there -- especially with TikZ commands it becomes really hard to predict how the compiler digests the material in this case. Here is the full code:

\documentclass{beamer}
\usetheme{Warsaw}
\usepackage{tikz}
\usepackage{hyperref}

\author{}

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


If you want to be fancy you may say

\let\oldalert\alert

before \title. That way you can continue write \title{Hello \alert{World}!}`.