# \hyperref to a \label doesn't work (“empty destination key”)

In one of my documents, I used the combination of \label with \hyperref. Now, I fail for some reason.

I included the package:

\usepackage[colorlinks=true,urlcolor=blue,linkcolor=blue]{hyperref}


Created a label somewhere in my text:

\label{key1}


And referenced it from the text:

\hyperref[key1]{there}


But xelatex gives me this:

Package hyperref Warning: Empty destination name,
(hyperref)                using UNDEFINED' on input line 66.


What am I doing wrong?

EDIT: Minimal working example:

\documentclass[a4paper, 12pt]{article}

\usepackage{xltxtra}

\begin{document}

Some text. \label{key1} Continuing.

Some more text (\hyperref[key1]{goto}).

\end{document}

-
Your MWE works fine for me. Pl. improve it to show the actual problem. – Harish Kumar Apr 23 '12 at 8:19
@HarishKumar - what version of xelatex do you have? I have "XeTeX 3.1415926-2.2-0.9995.2". – Rogach Apr 23 '12 at 8:21
@HarishKumar - That MWE actually shows my problem (on my machine) - the compiler outputs that error message, and link does not work. – Rogach Apr 23 '12 at 8:21
@Rogach: My Xetex version is : This is XeTeX, Version 3.1415926-2.3-0.9997.5 (MiKTeX 2.9) (preloaded format=xelatex 2011.12.21) 23 APR 2012 13:55 entering extended mode. Looks like you have to update your distro. – Harish Kumar Apr 23 '12 at 8:25
the repositories are out of date- your example works fine in the latest texlive. Please see Martin's answer to best-way-to-install-packages-for-texlive-in-ubuntu- you don't need to build the deb packages yourself, texlive 2011 comes with very easy executables that do all of the work – cmhughes Apr 23 '12 at 8:59

It seems that \label can be attached only to sections or subsections (or some other environments, like figures). To be able to reference arbitrary points in text, I needed to define "phantom section":

\phantomsection
\label{key1}

-
What hyperref needs, for sure, is a "hook" or "target." However, TeX does not "attach" a \label directly to the place where the command is encountered but, rather, to the "item" it's designed to cross-reference -- an equation, the header of a section of a section, the caption of a figure, etc. If, though, you need to create a hyper-target to a \label that's not associated with a known target type, it's necessary to specify \phantomsection (which might better be called \explicittarget). – Mico Apr 23 '12 at 11:01
Since hyperref 2010/04/17 v6.80x this is no longer necessary. The target is initialized with Doc-Start, that is set at the begin of the document. – Heiko Oberdiek Aug 7 '12 at 1:39

The repositories are out of date- your example works fine in texlive 2011 available at

http://www.tug.org/texlive/acquire-netinstall.html

Please see Martin's answer to Best way to install packages for TeXLive in Ubuntu?

You don't need to build the deb packages yourself, texlive 2011 comes with very easy executables that do all of the work for you. Once you have texlive 2011 installed, you can update it using tlmgr update --self --all`

-