What various packages, example code, or examples of existing documents with available source code are available to assist one in:

-
This post and this one combined with a study of the titletoc package might get you started :) – cmhughes Dec 17 '11 at 5:02
The document of tocloft package is a good start to learn. Then titletoc package. – Leo Liu Dec 17 '11 at 5:18
This is also interesting: wiki.contextgarden.net/Table_of_Contents – Ho1 Aug 4 '15 at 6:28

This post is community wiki, everybody is invited to edit.

## Packages

• tocloft: provides many features for customizing the ToC and the and the ability to create new "Lists of ..."
• titletoc: a companion for titlesec
• tocbasic: offers basic features for managing table of contents and similar lists, for package authors and class writers, is part of the KOMA-Script bundle
• tocstyle: provides many ways of customizing the ToC and such lists, still in development, is part of the KOMA-Script bundle
• minitoc: for adding mini-tables-of-contents (minitocs) at the beginning of every chapter, part or section
• tocbibind: can be used to add the ToC and/or bibliography and/or the index etc. to the table of contents
• tocvsec2: gives control over section numbering and/or the entries in the table of contents on a section by section basis
• etoc: (released a year after OP) claims a different approach than other toc packages. Instead of customizing an initial layout, you define "line-styles" for each toc level toc and can inject code for transitions between levels.

The memoir class provides features which are very similar to the capabilities of tocloft and tocbibind.

## Style gallery

Click on an image to go to the source code and the explanation.

-
Here you have another question with som examples how-to-customize-the-table-of-contents-using-tikz – Ignasi Dec 17 '11 at 15:55
@Ignasi Thanks, I added the examples! – Stefan Kottwitz Dec 17 '11 at 16:22
Nice answer. What about alternating dots like in the TeXbook toc? – Ho1 Aug 4 '15 at 6:29