Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am getting the following warning when I use beamer

Package hyperref Warning: Option `pdftitle' has already been used

I can recreate the problem with the following MWE based on the article class

\documentclass{article}
\usepackage[implicit=false]{hyperref}
\AtBeginDocument{\hypersetup{pdftitle=mytitle}}
\begin{document}
Hello world
\end{document}

For reasons that are beyond my understanding (and beyond my desire to know) beamer requires hyperref to be loaded with implicit=false. The \AtBeginDocument{\hypersetup{pdftitle=mytitle}} occurs in a package written by me. Given that I need to load hyperref with implicit=false and I need to set pdftitle after I load hyperref, is there a way to avoid this warning (without using the silence package)? Yes, I know it is only a warning and doesn't really matter.

Potentially helpful, but also potentially misleading is that

\documentclass{article}
\AtBeginDocument{\hypersetup{pdftitle=mytitle}}
\AtBeginDocument{\hypersetup{pdftitle=mytitle}}
\usepackage[implicit=false]{hyperref}
\begin{document}
Hello world
\end{document}

doesn't give the warning even though pdftitle is given twice.

share|improve this question
add comment

2 Answers

The setting of option pdftitle is used in \PDF@FinishDoc. Usually it is called at the output of the first page, but with option implicit it is done via \AtBeginDocument.

Thus, either you can use your call of \AtBeginDocument before package hyperref is loaded, or package etoolbox helps with hook \AtEndPreamble:

\documentclass{article}
\usepackage[implicit=false]{hyperref}
\usepackage{etoolbox}
\AtEndPreamble{\hypersetup{pdftitle=mytitle}}
\begin{document}
Hello world
\end{document}
share|improve this answer
add comment
up vote 0 down vote accepted

A little more digging and I think I have an answer. The issue is that implicit causes \PDF@FinishDoc to run earlier than usual. The default behavior of \PDF@FinishDoc is to disable the ability of \hypersetup to set pdftitle and instead cause it to produce a warning. A simple work around is to use \pdfinfo{/Title (mytitle)} instead of \hypersetup{pdftitle=mytitle}. My guess is that this has some drawbacks, but I don't know what they are yet. Another possibility is to redefine \PDF@FinishDoc so it runs later. I am hesitant to make it run later, since my guess is that there is a reason for it to run earlier with implicit. It might also be possible to either prevent pdftitle from being disabled, or to re-enable pdftitle, set it, and then disable it again.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.