8

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}
8

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}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.