TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use the hyperref package and defined custom settings as follows:


    bookmarks=true,         % show bookmarks bar?
    unicode=false,          % non-Latin characters in Acrobat’s bookmarks
    pdftoolbar=true,        % show Acrobat’s toolbar?
    pdfmenubar=true,        % show Acrobat’s menu?
    pdffitwindow=false,     % window fit to page when opened
    pdfstartview={FitH},    % fits the width of the page to the window
    pdftitle={My title},    % title
    pdfauthor={Author},     % author
    pdfsubject={Subject},   % subject of the document
    pdfcreator={Creator},   % creator of the document
    pdfproducer={Producer}, % producer of the document
    pdfkeywords={keyword1} {key2} {key3}, % list of keywords
    pdfnewwindow=true,      % links in new window
    colorlinks=true,        % false: boxed links; true: colored links
    linkcolor=red,          % color of internal links
    citecolor=green,        % color of links to bibliography
    filecolor=magenta,      % color of file links
    urlcolor=OliveGreen     % color of external links

I saw here that I can somehow put these settings into an external file to slim down the preamble. I created a hyperref.sty and moved the \hypersetup{} part in there. I noticed that it is considered in the compilation process, however, it fails.


What is the proper way to externalize the options for the hyperref package?

share|improve this question
If you load the package xcolor there is no need to load color. You can externalize the setup in an extra file which can be include by input – Marco Daniel Sep 7 '12 at 17:32
up vote 8 down vote accepted

just place the hypersetup command into myfile.tex then


don't create a file called hyperref.sty or you will prevent the original loading.

share|improve this answer


If the file hyperref.cfg exists, then package hyperref loads this file right before it processes its options. Therefore you can put many option settings via \hypersetup in this file. Options for PDF informations should be loaded after the package hyperref is loaded. In hyperref.cfg this can be done via:

  \hypersetup{pdfauthor={me}, ...}%

An extended example for hyperref.cfg:



In your original approach you cannot use hyperref.sty as file name, because this name is already used by the package itself. But via \input a different file name can be loaded:


But after hyperref is loaded, some options cannot be changed anymore.

Package myhyperref

A third approach is to write a small package:

\ProvidesPackage{myhyperref}[2012/09/07 v1.0]

  % ...
  % ...


Then the package is loaded via \usepackage in the main document:

share|improve this answer
How do I know which options have to be loaded before or after the package hyperref is loaded? – JJD Sep 7 '12 at 19:29
hyperref warns if an option is used too late. – Heiko Oberdiek Sep 7 '12 at 19:33
When I use your myhyperref example I end up with this error: Option clash for package hyperref. at line 10. I load the package as the last one. – JJD Sep 7 '12 at 19:43

Your Answer


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.