Friday, May 6, 2011

Annotated Table of Contents in LaTeX

I'd like to use LaTeX's \tableofcontents command (or some equivalent) to automatically generate a table of contents, but I'd also like to add a sentence or two to each line in the table of contents that describes what the referenced section is about. How can I do this?

From stackoverflow
  • Try

    \addcontentsline{toc}{section}{sample text}
    
  • I expect you can brute force and ignorance something using addcontentsline. eg:

    \addcontentsline{toc}{section}{text}
    

    however, this will conflict with automagically generated lines if you don't use the starred versions of sections it refers to.

    Anything more clean will require messing about with the relevant macros....unless I'm missing something.

  • Follwoing Oliver and simon's advice:

    You could redefine the sectioning commands to take a second (possibly optional) argument, and use that to build your argument to \addtocontentsline, and then involk the cooresponding section* command.

    Andreas : Thanks! Using your method, I can make it look like this: http://i43.tinypic.com/34jcaat.png -- not perfect, since it would be preferable if the page numbers and dots were in line with the headings, but much better than no annotations!
  • The tocloft package and its \cftchapterprecistoc command solved my problem.

    Will Robertson : The memoir class also provides this functionality (since it's by the same author)
  • Does anybody know how to eliminate de name of a section or subsection in the table of contents? I have proved *\section{name of the section} but this eliminates de number od the section in the document and I don't want this happen.

    Any ideas?

    Thanks!

  • I would change the {section} part to {subsection}.

    \addcontentsline{toc}{subsection}{sample text}
    

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.