Created
September 4, 2024 21:59
-
-
Save michal-h21/d9dba6a447d8391f62019b41ea963978 to your computer and use it in GitHub Desktop.
Sample usage of setting zref attributes and hyperref links
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\usepackage{zref} | |
\usepackage{zref-hyperref} | |
\usepackage{hyperref} | |
\usepackage{lipsum} | |
\makeatletter | |
\zref@newlist{zoo} | |
\zref@newprop{animal}{\currentanimal} | |
\zref@addprop{zoo}{animal} | |
\zref@addprop{zoo}{anchor} | |
\newcommand\setdest[2]{\edef\@currentHref{zoo:#2}% | |
\hyper@anchorstart{\@currentHref}\hyper@anchorend\def\currentanimal{#2}\zref@labelbylist{#1}{zoo}} | |
\newcommand\showref[1]{% | |
\hyperlink{\zref@extractdefault{#1}{anchor}{}}{\zref@extract{#1}{animal}}} | |
\makeatother | |
\begin{document} | |
\section{My favorite pets} | |
\setdest{label}{Cat} | |
Cats | |
\lipsum[1-5] | |
See the animal \showref{label}. | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment