[Tex/LaTex] Hyperref package is causing error message

errorshyperrefurls

I am trying to typeset my document, but the including the hyperref package gives me the following error:

The required file
tex\latex\url\url.sty is missing.

Now my problem can probably be solved by installing the url package, but my question is: Why do I have to do this? There are no odd references in my document. I even tried using it like this

    \documentclass[12pt,a4paper]{article}
    \usepackage{hyperref}
    \begin{document}
    Hello
    \end{document}

and it still produced the same error message.

So why won't this work? Is the hyperref package useless without the url package?

Best Answer

I think, links including URLs and their typesetting are an essential part of hyperref. Typesetting URLs does not need to be invented by hyperef, because package url already makes a good job. Therefore hyperref loads package url (and other packages) via \RequirePackage.

Of course, documents without any use of \url exists, thus a auto-load feature would be useful, but:

  • A package cannot be loaded after \begin{document}.

  • The first \url might be called in a group. All local definitions of the packages would be lost after the group (if package loading would be possible). Then at the next \url, the packages would have to be loaded again. But then the global resources are already present, possibly causing trouble.

  • Package hyperref could note the usage of \url in the .aux file and load the package url in \AtBeginDocument. But:

    • There are packages that can/should not be loaded at this late time.
    • One more LaTeX run is needed, because the first run might be garbage because of the missing package url.

A clean solution would be, if the TeX distribution takes care of package dependencies and install the required packages automatically, if a package is installed. For example, TeX Live maintains some dependencies. However, there are way too many packages to do this on a fine-granularity level. Each package has to be inspected and analyzed. And this needs to be repeated at each update of the package.

But there are not any volunteers, which are willing to dig through thousands of packages and to do this on a regular basis for new package and updates. And I do not see anyone, who is willing to pay for such a service.

AFAIK, there is just one person, who maintains MiKTeX, there is one person, who maintains the TeX Catalogue, there are a handful (at most) persons who maintain TeX Live and there are a handful (or less) persons that keep CTAN running.