I have a table with many entries and I want to reference the key so another person can quickly look up what the key means.

Here is some pseudocode:

snippet1\label{?key1} & longexplanatory text
snippet2\label{?key2} & longexplanatory text
snippet3\label{?key3} & longexplanatory text

connect \ref{key1} with \ref{key13}

After compilation I want the text to read

connect snippet1 with snippet3

The reader should be able to quickly jump to the table when clicking on snippet-N.


The following uses \refstepcounter (instead of the internal \@currentlabel) of a dummy counter to make the text to something that can be referenced. \raisebox moves \refstepcounter a bit to move the anchor position, if package hyperref is used. At the place of \refstepcounter hyperref sets the anchor.



\keylabel{snippet1}{key1} & longexplanatory text\\
\keylabel{snippet2}{key2} & longexplanatory text\\
\keylabel{snippet3}{key3} & longexplanatory text\\

connect \ref{key1} with \ref{key3}


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.