# \includeonlyframes and pdftitle

When I use beamer with \includeonlyframes{someframe}, the resulting PDF has the same pdftitle as the overall document. Is there any way to set the pdftitle to the title of the someframe, the only frame I am including?

\documentclass{beamer}
\includeonlyframes{frametwo}
\title{Document title}
\begin{document}%
\begin{frame}[label=frameone]{Frame one}
Spam
\end{frame}
\begin{frame}[label=frametwo]{Frame two}
Eggs
\end{frame}
\end{document}


Running pdflatex mini results in a PDF with title Document title. Is there any way to get the title of the only frame that is compiled?

-

## 1 Answer

You can set the pdftitle yourself using \hypersetup{pdftitle=<title>} after you disable the use of it by beamer using the usepdftitle=false option.

\documentclass[usepdftitle=false]{beamer}
\includeonlyframes{frametwo}
\hypersetup{pdftitle=frametwo}
\title{Document title}
\begin{document}%
\begin{frame}[label=frameone]{Frame one}
Spam
\end{frame}
\begin{frame}[label=frametwo]{Frame two}
Eggs
\end{frame}
\end{document}


If you need this often and/or like to avoid having the name written twice you could redefine \includeonlyframes to do this automatically:

\documentclass[usepdftitle=false]{beamer}

\makeatletter
\renewcommand\includeonlyframes[1]{%
\hypersetup{pdftitle={#1}}%
\def\beamer@framerestriction{#1,}%
}
\makeatother


However, I didn't found a way to switch usepdftitle off automatically if \includeonlyframes is used. With it off you won't get any title for all frames.

-
It would be nice to still have the pdftitle if I don't use \includeonlyframes. In my real use case I have a little shell-function calling pdflatex with pdflatex -halt-on-error -jobname="frame_$1" "\def\onlyframe{$1}\input{presentation}" and in my LaTeX-source conditionally call includeonlyframes if and only if \onlyframe is defined. So then I still need to figure out is if/how to pass usepdftitle=false as a late option to beamer if \onlyframe is defined. I'll look at it a bit more, maybe I can find it out. – gerrit Dec 14 '11 at 15:00
You can use \PassOptionsToClass{usepdftitle=false}{beamer}. – Martin Scharrer Dec 14 '11 at 15:49
Does this hack work if you pass more than one frame? – PatrickT Dec 8 '14 at 16:52
With more than one frame, might the following work? \makeatletter \renewcommand{\includeonlyframes}[2]{% \includeonlyframes[{#1}] \hypersetup{pdftitle={#2}}% \def\beamer@framerestriction{#1,}% } \makeatother \includeonlyframes{theframe1,theframe2}{thepdftitle} – PatrickT Dec 8 '14 at 17:38