# Can individual items in an itemize list be labelled and hyperref linked?

If I try to label items in a list as in

\documentclass{article}

\usepackage{hyperref}

\begin{document}

\begin{itemize}
\item blah \label{list:blah}

\pagebreak

\item foo \label{list:foo}

\pagebreak
\end{itemize}

reference to blah \ref{list:blah}
\pagebreak
reference to foo \ref{list:foo}

\end{document}


Then the links back to the items all go back to the beginning of the list. Is there a way to make each list item be separately labelled?

-
What do the \refs expand to? –  Joseph R. Nov 8 '12 at 15:49
\newlabel{list:blah}{{}{1}{\relax }{Doc-Start}{}} \newlabel{list:foo}{{}{2}{\relax }{Doc-Start}{}} –  Peeter Joot Nov 8 '12 at 15:54
I meant what do they appear like in the final document. –  Joseph R. Nov 8 '12 at 16:00
Answers to following question might be of help to create itemize lists with labels: tex.stackexchange.com/questions/74595/… –  mythealias Nov 8 '12 at 16:03
I edited the title, because the question wasn't really about whether you can label and reference individual list items, it is about getting the hyperref anchors to point to the right place. –  Seamus Nov 8 '12 at 16:15

It's uncommon to try to link to items within an itemize environment as they are unnumbered, and do not define anchors. There is no natural text to associate either.

By adding \phantomsection to every \item, you can provide anchors. There will still be no associated text, and hyperref will still complain of an empty link. Instead, you may use your own link text and the \hyperref command instead of \ref:

\documentclass{article}

\usepackage{hyperref}

\usepackage{etoolbox}
\AtBeginEnvironment{itemize}{\apptocmd{\item}{\phantomsection}{}{\errmessage{couldn't patch item}}}
\begin{document}

\begin{itemize}
\item blah \label{list:blah}

\pagebreak

\item foo \label{list:foo}

\pagebreak
\end{itemize}

reference to blah \hyperref[list:blah]{blah}
\pagebreak
reference to foo \hyperref[list:foo]{foo}

\end{document}

-

I don't think the links will work with itemize as you don't have a unique number to point to. An error is generated like

Package hyperref Warning: Suppressing empty link on input line 17.

Package hyperref Warning: Suppressing empty link on input line 19.


Try it with enumerate and it works:

\documentclass{article}

\begin{document}

\begin{enumerate}

\item blah \label{list:blah}

\pagebreak

\item foo \label{list:foo}

\pagebreak
\end{enumerate}

reference to blah \ref{list:blah}
\pagebreak
reference to foo \ref{list:foo}

\end{document}


If you want this to work with itemize you may use \pageref. But I am not sure to what extent this will be helpful in this case.

\documentclass{article}

\begin{document}

\begin{itemize}

\item blah \label{list:blah}

\pagebreak

\item foo \label{list:foo}

\pagebreak
\end{itemize}

reference to blah \pageref{list:blah}
\pagebreak
reference to foo \pageref{list:foo}

\end{document}

-