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.

Possible Duplicate:
Incorrect target of \label link produced by hyperref

Labeling and linking in LaTeX confuses me.

I have something like the following:

\section{main section}
\label{sec:mainsection}
 %lots of text
\label{SomethingDescribedButNotDocumentElement}
%more text

I want to be able to link to the second label, but it seems those labels are associated with the previous document element (in this case a main section)

So something like:

\hyperref[SomethingDescribedButNotDocumentElement]{link to 2nd label}

But this jumps up to the sec:mainsection label.

  • How do I link to an arbitrary section of my document (which may be not described by section or figure etc)?
share|improve this question

marked as duplicate by yo', cgnieder, egreg, bloodworks, Martin Schröder Jan 16 '13 at 23:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
maybe you want to use \pageref instead of \ref? –  cmhughes Jan 16 '13 at 22:25
    
is there another section or do you have 2 labels in the same section? –  Rico Jan 16 '13 at 22:29
1  
there are some good ideas in this question: When do I need to invoke \phantomsection?. –  barbara beeton Jan 16 '13 at 22:40
    
@Timebandit this would not be a problem if I did not have two labels in the same section/subsection/etc –  enderland Jan 16 '13 at 22:43
1  
@enderland It is not really a mistake to ask something that has been here before, as long as you don't mind getting it closed. –  yo' Jan 16 '13 at 22:50

1 Answer 1

up vote 10 down vote accepted

You can generate a new anchor by \phantomsection. The syntax of \hyperref with optional argument can be used to link an arbitrary text to this location:

\phantomsection
\label{SomethingDescribedButNotDocumentElement}

\hyperref[SomethingDescribedButNotDocumentElement]{Something}
share|improve this answer
    
Perfect! This is exactly what I needed. –  enderland Jan 16 '13 at 22:42
3  
It is not a bad question. However, we all know that it has been asked many times here. In my opinion, instead of answering it, the duplicate should be found and the question closed. –  yo' Jan 16 '13 at 22:46

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