[pdftex] Hyperref: problems linking to index generated with addcontentsline

Benjamin Deutsch Benjamin.Deutsch at informatik.uni-erlangen.de
Fri May 30 17:34:27 CEST 2003


On 30 May 2003, Andreas Matthias wrote:

> Next time, please, show us a full minimal example, with \documentclass,
> \begin{document}, \end{document}, etc. All <options> of hyperref are
> very important, you should not hide them, if you are interested in
> good answers.

Oops. Sorry! I've included a minimal document at the bottom of this mail,
if you're still interested (but I think the problem is solved now).

> \cleardoublepage
> \phantomsection
> > \addcontentsline{toc}{chapter}{Inhaltsverzeichnis}  % Yes, german...
> > \tableofcontents

Thanks, that seems to help. Someone else also suggested (privately) to add
a \refstepcounter{chapter} before the \addcontentsline, which also seems
to work (though it needs some \setcounter{chapter}{-1} -ing for the
toc...).

Thanks to everyone who answered,

  Benjamin Deutsch


Minimal document:

\documentclass[a4paper,12pt]{book}
\usepackage{makeidx}
\usepackage[plainpages=false,
  pdfpagelabels,
  naturalnames=true,
  dvips]{hyperref}
\hypersetup{colorlinks=true,
  linkcolor=black,
  pdfpagemode=None,
  pdfstartview=FitH}

\makeindex

\begin{document}
\addcontentsline{toc}{chapter}{Table of contents}
\tableofcontents

\chapter{One}
This is a \index{test} chapter.

\addcontentsline{toc}{chapter}{Index}
\printindex

\end{document}





More information about the pdftex mailing list