8

I have a long text and I want to create a link within the document to a particular paragraph (for example write something like "as shown here" where clicking on "here" will take the reader to that paragraph).

Is this possible to do?

15

The easiest way is to use a \hypertarget and \hyperlink pair:

Place the target (i.e. the place to be jumped to) with \hypertarget{foo}{Your text} and refer to it with \hyperlink{foo}{Some other text}.

The destination label foo must be unique of course.

If the link appears in \section{...} etc. arguments, care have to be taken. \hypertarget and \hyperlink have to be protected then with \protect and to comfort hyperref, put it into a \texorpdfstring{...}{...} command then!

Edit

If the position to be linked to is near a counter being increased with \refstepcounter, a usual \label{foo} and \ref{foo} is easier of course!

\documentclass{article}



\usepackage{blindtext}

\usepackage{hyperref}

\begin{document}
\section{With a hyperlink: \texorpdfstring{\protect\hyperlink{mylink}{As shown here}}{}}
\hyperlink{mylink}{As shown here}

\blindtext[5]

\hypertarget{mylink}{\textbf{Here is the anchor}}


\end{document}

enter image description here

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.