# Hyperref and lineno: always jumping to first page

I have a document where lines are numbered. I want to reference some special lines, for which the correct line numbers are generated. But using hyperref does not give the expected result: clicking on a line reference always moves me to the first page of the document, not the page which the referenced line is on. Check the following minimal example for reproducing my problem:

\documentclass[11pt]{article}

\usepackage{lipsum}
\usepackage{hyperref}
\usepackage[right]{lineno}

\begin{document}
\linenumbers
\lipsum[1-8]
\textbf{Here is the line, I want a reference to.}\linelabel{test}
\lipsum[5-8]
\textbf{Here is the line, where I refence a the special line (on page two):
\ref{test}}
\end{document}


I'm using pdflatex.

You can set up a system for creating such references using hyperrefs commands \hypertarget and \hyperlink. I have called the labelling command \llabel and the reference command \lref. The llineno: prefix is to avoid clashes with other target names.

\documentclass[11pt]{article}

\usepackage{lipsum}
\usepackage[right]{lineno}
\usepackage{hyperref}

\newcommand{\llabel}[1]{\hypertarget{llineno:#1}{\linelabel{#1}}}