Document ClassesHyperref and Table of Contents issues

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
Simon Halliday
Posts: 5
Joined: Mon Jun 02, 2008 6:52 pm

Hyperref and Table of Contents issues

Post by Simon Halliday »

Hi Ladies and Gents,

I have been having issues because I am trying to use the hyperref package, but I don't want numbered sections. Hence I have used the following to get a section into the contents page:
\addcontentsline{toc}{subsection}{"section name"}

But, I want the text that appears from the \addcontentsline command to act as a hyperref. Currently all that is happening is that all of the lines in the ToC are hyper-referenced to the the table of contents page, rather than to the pages on which their content appears. Any ideas?

Thanks,
Simon

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10322
Joined: Mon Mar 10, 2008 9:44 pm

Hyperref and Table of Contents issues

Post by Stefan Kottwitz »

Hi Simon,

that should work, I think. Try this minimal example:

Code: Select all

\documentclass[a4paper,10pt]{article}
\usepackage{hyperref}
\begin{document}
\tableofcontents
\newpage
\section*{One}
\addcontentsline{toc}{subsection}{One}
Text	
\newpage
\section*{Two}
\addcontentsline{toc}{subsection}{Two}
Text
\end{document}
Do you get correct links to the pages?

Perhaps consider to use \phantomsection.

Stefan
LaTeX.org admin
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Hyperref and Table of Contents issues

Post by gmedina »

We will need a minimal working example showing this behaviour.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Simon Halliday
Posts: 5
Joined: Mon Jun 02, 2008 6:52 pm

Re: Hyperref and Table of Contents issues

Post by Simon Halliday »

Problem solved. Thanks Stefan.
Post Reply