My document has both starred and non-starred version of section, and I want to add both types to my table of contents. I am using titletoc and I tried to solve it as follows:



[, ][.\vspace{0.5em}]

This almost works as I want, apart from two problems:

  1. When I use a \section* in my document, I get the following warning:

Package hyperref Warning: The anchor of a bookmark and its parent's must not (hyperref) be the same. Added a new anchor on input line 160.

  1. Sometimes in the generated table of contents, there is a space between the end of the section heading and the comma separating it from the next heading, like this:


A section heading 1, A starred section heading 1 , another section heading 1.

I tried changing the end of my titlecontents definition to:

[\unskip, ][.\vspace{0.5em}]

which did get rid of some of the undesired spaces, but not all of them. I have no idea what is causing the extra space to be generated. Help!


I would suggest you create your own sectioning commands:


You need to create one command for nonum-chapter, -subsection, etc. That's how I always do it.

  • Thanks for the suggestion. I tried it but it didn't solve either of the issues.
    – Michael D.
    Mar 12 '16 at 18:02

OK, with a lot of trial and error I finally figured out a solution.

To get rid of the hyperref warning : use \phantomsection :

% how to handle \section*

To get rid of the space that appears before the comma separator when section* entries appear in the TOC :

Even though I am not displaying subsection or lower in the TOC:


it is still necessary to define a \titlecontents line for subsection and subsubsection. Then the mysterious spaces vanish.

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.