My answer to Problem using \alert{} in Beamer title with metropolis theme solves an incompatibility problem between TiKZ
and \title
with \protect
-ed contents in beamer
documents.
Following code fails:
\documentclass{beamer}
\usepackage{tikz}
\title{Hello \protect\alert{World}!} %<- before \begin{document}
\begin{document}
\maketitle
\end{document}
and next one works
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\title{Hello \protect\alert{World}!}%<- after \begin{document}
\maketitle
\end{document}
If the title is \title{Hello World!}
, there's no problem placing it in preamble.
I found the answer by trial and error and because I remembered some similar answer in TeX.SX. I would like to know why the error happens and why the solution works.
While I was writting this question Should I place \title, \author, \date in the preamble or after \begin{document}? appeared in my browser. My resume from it is that it doesn't matter if title commands are declared in preamble or inside the document before \maketitle
except when it matters. Then my question is when it matters? Only in beamer
? when using \protect
? when using TiKZ
? Is there any general recipe?
babel
answer to the other question. A summary of that discussion could be: if the title is plain text there is no problem with the placement, if it contains formatting commands, shorthands, etc. then it can be necessary to put the\title
command in the document body. – Andrew Swann Apr 19 '16 at 8:46\title{Hello \texorpdfstring{\alert{World}}{World}!}
with the help ofhyperref
. – Ruben Apr 19 '16 at 9:00\hypersetup{pdftitle={\inserttitle\ifx\insertsubtitle\@empty\else\ - \insertsubtitle\fi}}
. So if it tries to write the pdf info at the start of the document it encounters problems if control sequences etc. are part of the title. If the title is only defined after the informations are written to the pdf, it does not matter if the title contains something crazy. – samcarter_is_at_topanswers.xyz Jul 14 '16 at 0:11