If you use Apple Pages you'll know that getting the table of contents (TOC) to cooperate isn't that easy.
see this page:
It doesn't tell you how to generate a TOC though. To do that, you have to select a few styles in the styles drawer, and use them, and then under the Inspector -> Document -> TOC choose those styles to appear in the TOC. Then go to Edit -> insert TOC.