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.

When I type \ref{name} giving the link is on the wrong page. How do I fix this?

\documentclass[a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage{theorem}

\newtheorem{teo}{Teorema}[chapter]
\begin{document}
\begin{teo}\label{tvi}
text
\end{teo}
... %insert various \newpage
\ref{tvi}
\end{document}

Returns incorrect page.

share|improve this question
6  
Please post a full minimal example. –  Joseph Wright Sep 25 '11 at 20:14
5  
Does teo include a \refstepcounter? Otherwise the \label might point to the last label-able item (e.g. section) instead. –  Martin Scharrer Sep 25 '11 at 20:21
2  
You are talking about links, but your code doesn't show you load hyperref; also teo doesn't exist in standard LaTeX, so you have to show its definition. –  egreg Sep 25 '11 at 20:32
2  
The theorem package is obsolete, all its functionality is present in ntheorem. Apart from this, I don't see any problem and after adding \lipsum paragraphs I always get the correct link. –  egreg Sep 25 '11 at 20:56
2  
You mention that the link jumps to an "incorrect page". Do you perhaps have another object using the label tvi? You'll know this is the case your log file contains the output "LaTeX Warning: There were multiply-defined labels." near the end. –  Werner Sep 25 '11 at 21:42
show 2 more comments

2 Answers 2

Your example works fine for me.

share|improve this answer
add comment

Your example works fine for me.

  • Follow the advice given by cmhughes
  • Did you compile your document at least twice? Check for any rerun warnings in the log-file, e.g.

    LaTeX Warning: Reference `tvi' on page ... undefined on input line 34.

    Package rerunfilecheck Warning: File `....out' has changed.

    (rerunfilecheck) Rerun to get outlines right

    (rerunfilecheck) or use package `bookmark'.

    LaTeX Warning: There were undefined references.

    LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.

  • Place a \phantomsection before \begin{teo}.

Where does the link in your example lead to? The page before or after the \begin{teo}, to the first page of your document, ...?

share|improve this answer
add comment

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.