Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

It is possible to make a hyperref to go to page x, but how we can define a custom anchor to go a destination line?

For example:

\documentclass{article}
\usepackage{lipsum}

\begin{document}
  \lipsum[1]
  \lipsum[2]
  THE DESTINATION LINE (anchor x)
  \lipsum[3]
  \lipsum[4]
  CLICK HERE (go to anchor x)
  \lipsum[5]
\end{document}

How to click on CLICK HERE and goes to the DESTINATION LINE? I mean displaying THE DESTINATION LINE as the first line in the pdf reader.

share|improve this question

2 Answers 2

up vote 10 down vote accepted

Use either \hypertarget + \hyperlink or \phantomsection with a \label and \hyperref:

\documentclass{article}
\usepackage{lipsum,hyperref}

\begin{document}
  \lipsum[1]
  \lipsum[2]
  \phantomsection\label{here}THE DESTINATION LINE (anchor x)
  \lipsum[3]
  \lipsum[4]
  \hyperref[here]{CLICK HERE} (go to anchor x)
  \lipsum[5]

  \lipsum[1]
  \lipsum[2]
  \hypertarget{here2}{}THE DESTINATION LINE (anchor x)
  \lipsum[3]
  \lipsum[4]
  \hyperlink{here2}{CLICK HERE} (go to anchor x)
  \lipsum[5]
\end{document}
share|improve this answer

You can use \hyperlink and hypertarget from hyperref.

\documentclass{article}
\usepackage{lipsum}
\usepackage{hyperref}
\begin{document}
  \lipsum[1]
  \lipsum[2]
  \hypertarget{mylink}{THE DESTINATION LINE (anchor x)}
  \lipsum[3]
  \lipsum[4]
  \hyperlink{mylink}{CLICK HERE (go to anchor x)}
  \lipsum[5]
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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