Suppose I am writing a book in which some sections are especially important. I would like those sections to be identified by a * after the page number in the table of contents. How do I get it there?

I can get extra stuff into the table of contents by putting \addtocontents into my text at appropriate places. So in this case I'd presumably write something like \addtocontents{\protect\marginpar{*}} in my text in appropriate places.

But that's not right, because \marginpar tries to put its contents into the outside margin. I always want to put the * into the right margin, regardless of whether I'm on an even or odd page.

It seems like it should be extremely easy to do this, but I can't see how. Suggestions?

  • It helps partly. However, I don't really want to put the symbol along with the section number; I want to put it after the page number so that it sticks out into what would otherwise be the margin of the table of contents. Also, ideally I would not want to have to decide as part of the section macro whether to use the special symbol; I'd like it to appear if and only if I invoke a particular macro at any time within the section body (which is part of why I'd like the symbol to appear at the end rather than the beginning of the table-of-contents line). Commented Feb 5, 2012 at 2:59

1 Answer 1


Using \marginpar may not be the best way to do this, but it is in fact not too difficult to set up (assuming there aren't any other \marginpars within the scope of the TOC, but then there wouldn't be any normally).

So what what needs doing? Basically when the \marginpar is encountered we have to prevent LaTeX from choosing the outside margin. Instead we have to make it do what it it does when the option twoside isn't choosen. And that is basically setting the switch @mparswitch to false before typesetting the TOC and to true afterwards (if \marginpars within the document should switch margins. This could then look like this:




\marginparright \tableofcontents \marginparoutside


test \marginpar{outside?}

\addtocontents{toc}{\protect\newpage} % generate a pagebreak in toc for testing

\section[Again Important\marginpar{*}]{Again Important on page 2 in TOC}
test \marginpar{outside?}

And the result (second page) would be:

enter image description here


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .