1

I'm trying to strip \cite, \footnote, etc. from beamer frame titles for pdf strings. I generate bookmarks for all my frame titles using \bookmark[page=\the\c@page,level=3]{\beamer@frametitle}, so whenever such commands arise in a frame title, they cause trouble. I know I can manually solve these using \texorpdfstring, but I'd rather like to have defaults that "just work", as these errors are easy to miss.

This works okay for the basic cases of \boldmath and \cite{key}, but I cannot get it to work with commands that have optional parameters such as

\footnote[frame]{footnote text}

I have tried for example

\pdfstringdefDisableCommands{%
  \def\boldmath{}% easy case you'll find in many examples
  \def\cite{\@gobble}% supposedly does not work with optionals either
  \renewcommand<>{\footnote}[1][]{}%
}

but that does not work.

Minimally working example (the problem is in the PDF bookmarks!):

\documentclass{beamer}
\usepackage{hyperref,bookmark}
\makeatletter
\setbeamertemplate{frametitle}{\insertframetitle
  \bookmark[page=\the\c@page,level=3]{\beamer@frametitle}}
\makeatother

\begin{document}
\begin{frame}{Frametitle \footnote[frame]{Footnote}}
  Frame text
\end{frame}
\end{document}

This file will have a bookmark like "Frametitle [frame]Footnote". I only want "Frametitle". And I want to solve this globally, not locally by wrapping as \texorpdfstring{\footnote[frame]{Footnote}}{} (that works, but requires going through all problematic frames individually). Problem with bookmarks

1 Answer 1

3
\documentclass{beamer}
\usepackage{hyperref,bookmark}
\usepackage{xparse}
\makeatletter
\setbeamertemplate{frametitle}{\insertframetitle
  \bookmark[page=\the\c@page,level=3]{\beamer@frametitle}}
\makeatother
\NewExpandableDocumentCommand\gobbleoptandarg{om}{}
\pdfstringdefDisableCommands{\let\footnote\gobbleoptandarg}%
\begin{document}
\begin{frame}{Frametitle \footnote[frame]{Footnote}}
  Frame text
\end{frame}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .