2

I would like to cross reference to specific words in a document so that when I click on a word, it will bring me to a specific place in the document; similar to a hyperlink, except the 'URL' would be within the document.

I originally tried:

\label{} and tried referencing it with \ref{}, however I believe \label{} needs to be within an environment or counter to work properly. So, I then tried the hyperref package, however I can't figure out any way to get that to make links within the document itself.

Is there any way to do this? Perhaps a different package?

Fran
  • 80,769
Manofzelego
  • 169
  • 1
  • 2
  • 11
  • I did a bit of quick research using texdoc.net. First I checked the hyperref documentation about bookmarks, which then recommended the use of the bookmark package. I checked its documentation, again using texdoc.net. This will do what you want. There is an example in the documentation you can run to understand how it works. – R. Schumacher Mar 25 '15 at 03:13

1 Answers1

5

You can use \hyperlink and \hypertarget of the hyperref package. In this MWE the link jump to page 3:

\documentclass{article}
\usepackage[colorlinks]{hyperref}
\begin{document}
Some \hyperlink{label}{link caption}
\newpage
Some text
\newpage
The \hypertarget{label}{target caption}
\newpage
Some text
\end{document}
Fran
  • 80,769
  • Nice and simple! Now, how to get in link caption the page number where target caption is? – tatojo Dec 26 '19 at 15:10
  • @tatojo For that you can use \pageref{label} and \label{label} target caption, but also loading hyperref. – Fran Dec 26 '19 at 18:40
  • that was my first choice, but when I click on pageref, it takes me several pages before the target caption. – tatojo Dec 27 '19 at 16:35
  • @tatojo Because the label and the supposed target are not really ending in the same page in the PDF. If you write \mbox{\label{label} x} or \begin{figure} x \label{label}\end{figure} \pageref should point to the page with the target "x". But if you write \label{label} x at the very end of some page, maybe only the "x" pass to the next page. And in case of \label{label}\begin{figure}[p] \end{figure}, the float with the target can move several pages with respect the label. – Fran Dec 27 '19 at 18:31