59

I once read about an option for hyperref that automatically takes the info provided via the standard \author and \title, and puts it into the pdfinfo. Now I want to implement it in my template and can't find it anywhere in the hyperref manual nor anywhere else.

Did I dream about this or can someone help me out here?

(A similar, but more general question: Is hyperref really the best way to add metadata to a TeX file?)

2 Answers 2

67

The option is pdfusetitle. It is described in the hyperref README file.

5
  • 10
    Ah, that's where I saw it, thanks! For some reason it only seems to work as \usepackage[pdfusetitle]{hyperref} and not as \hypersetup{pdfusetitle} though.
    – doncherry
    Commented May 2, 2011 at 22:11
  • @doncherry: Yeah, a few options are like that. I suppose they require special arrangements to be made at load time...
    – SamB
    Commented May 3, 2011 at 3:58
  • 7
    As of April 2012, this option is not described in the hyperref manual. Any reason for that?
    – Olivier
    Commented Jul 7, 2012 at 10:13
  • 1
    This doesn't work (anymore?). It gives the following warning: Package hyperref Warning: Option `pdfusetitle' has already been used, setting the option has no effect on input line 44. and has no effect (in that the PDF has no title or author set automatically). Commented Jul 15, 2015 at 12:48
  • @NajibIdrissi The warning only says, that pdfusetitle was set too late. It needs to be set at package loading time (\usepackage). Commented Oct 30, 2016 at 17:00
26

You could also use

 \makeatletter
 \hypersetup{pdftitle={\@title},pdfauthor={\@author}}
 \makeatother

(edit: makeat* pointed out by Joseph Wright)

7
  • 5
    This needs \makeatletter, of course.
    – Joseph Wright
    Commented May 3, 2011 at 11:27
  • This might be a nice alternative if pdfusetitle fails -- the readme says it "tries to derive the values", so a failure for whatever reason apparently can't be excluded.
    – doncherry
    Commented May 3, 2011 at 15:18
  • @Joseph: Would \makeatletter be called before (and \makeatother after) \hypersetup{...} or separately for each argument? Considering that I have up to nine or ten arguments for \hypersetup and considering how mighty and thus dangerous hyperref is, it might cause conflicts if placed around the entire command?
    – doncherry
    Commented May 3, 2011 at 15:23
  • @doncherry: \makeatletter before \hypersetup and \makeatother after it.
    – Joseph Wright
    Commented May 3, 2011 at 15:37
  • @doncherry the readme is right, pdfusetitle will fail if you have any non ASCII character in your title or author name, with the error ** WARNING ** Failed to convert input string to UTF16... That's why this method, with your addendum is the best.
    – Andrei
    Commented Oct 8, 2015 at 7:52

You must log in to answer this question.

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