2

In my document I have a number of chapters, that have their numbering suppressed. I know that to append them to the table of contents one should use the \usepackage{etoolbox} and subsequently define

 \chapter*{Name of the chapter}
 \addcontentsline{toc}{chapter}{Name of the chapter}

This does the job and I get my chapters properly included. Unfortunately when using a Pdf viewer, I get a mismatch between the positions of the chapters and links in the table of contents. Clicking the name of the chapter, included via \addcontentsline{toc}{chapter}{Name of the chapter}, gets me to the wrong page. This is not the case for the normal chapters, but still is quite annoying.

Does anyone has ideas how this issue can be resolved?

  • 2
    Welcome to TeX.SX! You don't need etoolbox for that, but you do need \phantomsection before \chapter* – egreg Nov 17 '15 at 17:35
  • 2
    (1) welcome, (2) you do not need etoolbox for this, (3) always post full minimal examples, (4) I'm guessing you are using hyperref, in that case you need \phantomsection before \addcontentsline . The reason being that the hyper link need something to latch on to and \chapter* provides nothing – daleif Nov 17 '15 at 17:37
  • Thank you both. You solved my problem! The problem was the missing \phantomsection and a potential conflict with \usepackage[pdftex]{hyperref} . I apologize for not providing a minimal example, next time I will know. Could you formulate your answers so that I can accept them. – Alexander Cska Nov 17 '15 at 17:57
  • @AlexanderCska: Unfortunately you can accept only one of the answers then ;-) And both haven't seen your comment probably because they weren't addressed properly: Use a @ in front of the user-name to write an answer-comment to a user here – user31729 Nov 17 '15 at 19:33
  • @ChristianHupfer added – daleif Nov 17 '15 at 19:57
2

Whenever \addcontentsline is used in conjunction with, say, \chapter* and the hyperref package is used, you need to use

\chapter*{...} 
\phantomsection 
\addcontentsline... 

Because hyperlinks needs something to latch on to. Normally it would latch on to the changing chapter counter, but here no counter is used, so a phantom is needed.

  • Possibly \cleardoublepage\phantomsection before \chapter*, so the anchor will show the chapter title. – egreg Nov 17 '15 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.