# hyperref warning caused by Beamer appendix

The code below results in the following warning: "Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding): removing '\translate' on input line 16."

(Note: line 16 is the blank line immediately following \appendix.)

This warning occurs even if I remove the supplemental slide and leave \appendix as the last line before \end{document}. The warning does not occur if I remove the appendix entirely. The .pdf file produced is apparently correct, but I'd like to be able to include an appendix without encountering the warning.

I looked through the previously answered questions and found references to the \texorpdfstring command, but I couldn't seem make it work in this case. Has anyone found a solution, or can anyone point me to a previously answered question that I may have missed? Thanks!

\documentclass{beamer}
\title{The Title}
\author{The Author}
\begin{document}

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

\section{First Section}
\begin{frame}\frametitle{First Section}
This is a slide.
\end{frame}

\appendix

\section{Appendix}
\begin{frame}\frametitle{Supplemental Material}
This is a supplemental slide.
\end{frame}

\end{document}

-
The problem is the definition of \appendix in beamerbasesection.sty which uses \part{\appendixname} and \appendixname is defined in beamerbasemisc.sty as \translate{Appendix}. –  Gonzalo Medina Jul 22 '14 at 14:29

You can work around this warning by using

\documentclass{beamer}
\title{The Title}
\author{The Author}

\renewcommand\appendixname{Appendix}

\begin{document}

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

\section{First Section}
\begin{frame}\frametitle{First Section}
This is a slide.
\end{frame}

\appendix

\section{Appendix}
\begin{frame}\frametitle{Supplemental Material}
This is a supplemental slide.
\end{frame}

\end{document}


EDIT

The Reason for the warning was explained in @Gonzalo Medina's comment

The problem is the definition of \appendix in beamerbasesection.sty which uses \part{\appendixname} and \appendixname is defined in beamerbasemisc.sty as \translate{Appendix}

-
Thanks very much! I'll vote your answer up when (if) I get to 15 reputation points. –  skepticaleye Jul 22 '14 at 14:35
If you want to, you can add to your answer the reason for the warning (I gave it in a comment to the question). –  Gonzalo Medina Jul 22 '14 at 14:37

Using the babel package also resolves the issue as \translate{Appendix} produces a decent name.

-

Macro \translate is defined in package translator. It is defined with an optional argument with many assignments in the implementation. Therefore it is not expandable and cannot be used in bookmarks this way.

The following code provides \bkmtranslate, a poor man's definition of \translate without support for an optional argument. Also the language search of the original \translate is not implemented. Instead, the language is defined as macro \bkmtranslateto. The default is \languagename. If the translation is not found, then the argument is used without modification, the same behavior as the original \translate except, that the original \translate can extend the search to more than one language.

\pdfstringdefDisableCommands is used to install \bkmtranslate as replacement for \translate in the bookmarks:

\documentclass{beamer}

\makeatletter
\newcommand*{\bkmtranslateto}{\languagename}
\newcommand*{\bkmtranslate}[1]{%
\ifcsname tr@@@\bkmtranslateto @#1\endcsname
\csname tr@@@\bkmtranslateto @#1\endcsname
\else
#1%
\fi
}
\pdfstringdefDisableCommands{\let\translate\bkmtranslate}
\makeatother

\usepackage{bookmark}% not needed here, but faster bookmark updates

-