Document ClassesIncorrect Link in ToC to Bibliography Heading

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
fastest
Posts: 5
Joined: Fri Nov 14, 2008 5:39 pm

Incorrect Link in ToC to Bibliography Heading

Post by fastest »

Dear All! :ugeek:

I would like to submit a problem that I have using the hyperref package!

Normally everything work perfectly, using the following code:

Code: Select all

\usepackage[bookmarks]{hyperref}
\usepackage[figure,table]{hypcap}
The second package hypcap is really useful to mark the floating objects.

Now the problem is this. When I write the bibliography I insert it in the document as this.

Code: Select all

\chapter*{Bibliography}
\addcontentsline{toc}{chapter}{Bibliography}
This means that it will not be inserted in the table of contents. Only the second line makes the Bibliography visible in the ToC. Now it comes the problem. When I click on the "Bibliography" in the ToC to use the hyperlink, the document leads me not to the page in which the bibliography starts, but in the page above the bibliography.

It is not such a problem, but still does anyone know how to fix it?

Thank you for the attention.

Regards
Gabriele Colosimo

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
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Incorrect Link in ToC to Bibliography Heading

Post by localghost »

This way of bringing the bibliography into the ToC doesn't produce an anchor for hyperref. Hence it generates a false page link. You may try the tocbibind package and omit the manual insertion of the bibliography in the ToC. This is procedure for a standard document classes. Other classes may have built-in features.


Best regards
Thorsten
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Incorrect Link in ToC to Bibliography Heading

Post by Juanjo »

Instead of using tocbibind, in the standard book class, you can put this just right before the bibliography.

Code: Select all

\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{\bibname}
As localghost said, other classes may require a different approach.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
fastest
Posts: 5
Joined: Fri Nov 14, 2008 5:39 pm

Incorrect Link in ToC to Bibliography Heading

Post by fastest »

Thank you very much for your answers.

I tried using the package tocbibind and it worked quite good!

I am sorry I haven't tried yet the second solution proposed by Juanjo, but I will do is as soon as possible. :D

Thank you for your knowledge and efficiency.

Regards
Gab
Post Reply