I dont understand why my hyperref
is not going to the page I wanted when I click it on my table of content?
\documentclass[12pt, a4paper, oneside]{report}
\usepackage[T1]{fontenc}
\usepackage{mathptmx} %times font
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{enumerate}
\usepackage{hyperref}
\usepackage{setspace}
\usepackage[english]{babel} %roman & arabic label page
\usepackage[top=50mm , bottom=50mm, left=45mm, right=45mm]{geometry}
\addto\captionsenglish{% Replace "english" with the language you use
\renewcommand{\contentsname}%
{Table of Contents}% change "Contents" (default) to "Table of Contents"
}
\hypersetup{
colorlinks=true, %set true if you want colored links
linktoc=all, %set to all if you want both sections and subsections linked
linkcolor=black, %choose some color if you want links to stand out
}
\pagenumbering{Roman}
\begin{document}
\input{CoverPage}
\thispagestyle{empty}
\pagebreak
\input{TitlePage}
\thispagestyle{empty}
\pagebreak
\input{CopyrightPage}
\addcontentsline{toc}{chapter}{Copyright}
\setcounter{page}{1}
\pagebreak
\input{DeclarationPage}
\addcontentsline{toc}{chapter}{Declaration}
\pagebreak
\input{AcknowledgementPage}
\addcontentsline{toc}{chapter}{Acknowledgement}
\pagebreak
\tableofcontents
\addcontentsline{toc}{chapter}{Table of Contents}
\pagebreak
\addcontentsline{toc}{chapter}{List of Figures}
\listoffigures
\pagebreak
% % (1) =========================================
\pagenumbering{arabic}
\addcontentsline{toc}{chapter}{1. Introduction}
\input{Introduction}
\setcounter{chapter}{1}
\pagebreak
Best Answer
There are multiple issues with the O.P. code...
\cleardoublepage\phantomsection\addcontentsline{...}
if some content must be explicitly added to a ToC\usepackage{tocbibind}
is the cleaner solutionIntroduction
should be real chapter and not something with\section
andsubsection
. This screws up the bookmarking etc. and numbering.\input
is too much for my taste -- It makes editing (and debugging) very difficult.Some notes on
\phantomsection
etc.If content is to be added to a
.toc
etc. file,\addcontentsline{toc}{...}{...}
is most times the right choice. However, if this happens without a\cleardoublepage
(or\clearpage
) in conjunction with\phantomsection
, the link will go to a previous page.The
\phantomsection
can be omitted however, if a command like\chapter*
etc. is used. An anchor related tochapter*
is inserted byhyperref
then. For more information, see sectionin the
hyperref
manual please.For the individual
FooPage.tex
files I used basically this codeReplace
Foo
with the relevant name (Exception:TitlePage.tex
is\maketitle
only)The individual
\phantomsection
commands aren't necessary if\chapter*
etc is used, but I kept them, since it's unclear what's inside the real\input{...}
files.