1

I'm quite new with Overleaf and I have following problem: I want to make clickable table of contents to my thesis. It turned out that package hyperref works only with numbered chapters and sections. I still have some unnumbered chapters like abstract, foreword and introduction and I want to add them manually to toc.

So I decided to use the implementation where I try to figure out for example the page number of abstract with \pageref command, when there is created label inside of abstract with \label command.

Here is the example code:

\begin{abstract}
\label{hyp:abstract}

Some text...

\end{abstract}

.sty file

.
.
.
\addtocontents{toc}{\protect\contentsline{chapter}{ABSTRACT}{}{page.\pageref{hyp:abstract}} }
.
.
.

Edit: These chapters abstract, foreword and introduction are not exactly chapters but headers and own similar kind of structures compared to \chapter.

I have tried several ways of implemented this but always get hundreds of errors and I have no clue what is the proper way to do it. Thanks in advance!

  • 1
    In that case, please show an MWE (emphasis on minmal and compilable) that demonstrates your problem. As it stands, we can only guess the details of your problem. – schtandard Jun 06 '19 at 13:58
  • This topic can be closed/removed. I found out that .sty file command should be edited following: \addtocontents{toc}{\protect\contentsline{chapter}{ABSTRACT}{}{page.\thepage}}. – T. Holmström Jun 06 '19 at 14:53

1 Answers1

1

You can add an arbitrary destination anchor with \phantomsection.

\documentclass{book}
\usepackage{hyperref}

\begin{document}
\tableofcontents

\chapter{numbered}
\newpage
\chapter*{unnumbered}
\addcontentsline{toc}{chapter}{unnumbered}
\newpage
\phantomsection unnumbered 2
\addcontentsline{toc}{chapter}{unnumbered 2}
\end{document}

enter image description here

Ulrike Fischer
  • 327,261