Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I use the great package zref to create my own referencing system. Can I make hyperlinks for pdftex (and tex4ht)?

See the following code. I'd like to make the \showref command clickable, so that I jump to the place where I use the \setdest command. Is this (easily) possible?

\documentclass{article}
\usepackage{zref}
\makeatletter
\zref@newlist{zoo}
\zref@newprop{animal}{\currentanimal}
\zref@addprop{zoo}{animal}
\newcommand\setdest[2]{\def\currentanimal{#2}\zref@labelbylist{#1}{zoo}}
\newcommand\showref[1]{\zref@extract{#1}{animal}}
\makeatother

\begin{document}
\section{My favorite pets}
\setdest{label}{Cat}

See the animal \showref{label}.
\end{document}
share|improve this question

1 Answer 1

up vote 6 down vote accepted

According to the zref manual, hyperref is left as a future work.

However, you could at least use the normal \phantomsection trick, and another label:

\documentclass{article}
\usepackage{zref}
\makeatletter
\zref@newlist{zoo}
\zref@newprop{animal}{\currentanimal}
\zref@addprop{zoo}{animal}
\newcommand\setdest[2]{\def\currentanimal{#2}\zref@labelbylist{#1}{zoo}\phantomsection\label{zref:#1}}
\newcommand\showref[1]{\hyperref[zref:#1]{\zref@extract{#1}{animal}}}
\makeatother

\usepackage{lipsum}

\usepackage{hyperref}

\begin{document}
\section{My favorite pets}
\lipsum[1]

\setdest{label}{Cat}
Cat goes here.

\lipsum[2]

\section{Other}
See the animal \showref{label}.
\end{document}
share|improve this answer

Your Answer

 
discard

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.