Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to know how to create a table of contents in LaTeX. For example, if I were to write a book, I would want something like this

Contents

    Chapter 1
      1.1 Real Analysis .............. 1
      1.2 Role of LUB Axiom........... 3

How do I create this? I'd like to know.

share|improve this question
4  
This is generally referred to as table of contents, the index is the list of important words with page reference that is typically at the very end of a book. –  Caramdir Aug 12 '10 at 13:24
    
@Caramdir: Your comment's content is correct, but why comment rather than edit the question as I have done? (I suggest that you and I both ought to delete these comments, given the edit.) –  vanden Aug 12 '10 at 14:58
    
The comment is for education purposes. I'm sure other people - especially non-native speakers - are confused about this too. Generally I avoid doing any edits that potentially significantly change the meaning of questions. Though in this case you are probably right that I should have corrected the question too. –  Caramdir Aug 12 '10 at 21:47

2 Answers 2

A table of contents (ToC) is produced by inserting \tableofcontents at the appropriate place in your document.

\documentclass{book}

\begin{document}

\tableofcontents

\chapter{(Chapter Name)}

\section{Real Analysis}

\section{Role of LUB Axiom}

\end{document}

Note that you need at least two LaTeX runs to produce the ToC (LaTeX collects the data for the ToC in the first run and typesets it in the second run). If the ToC itself comprises several pages, a third LaTeX run may be necessary to get the ToC's page references right.

share|improve this answer

There's just one command necessary: \tableofcontents, as already mentioned by lockstep. It takes the entries from the sectioning commands \part, \chapter, \section etc.

Additionally, you could use the optional argument of a sectioning command to get a different, shorter entry for the table of contents, for example:

\section[short entry]{long title}

This is useful if you have very long titles in the body text but need shorter list entries in the table of contents.

There are package for further customization of the contents list, if desired, for example:

A very similar index could be created for your figures and tables. The commands are \listoffigures and \listoftables. I mention it because it's the same concept, here the content entries come from the \caption commands.

share|improve this answer
1  
IMO, tocbasic is rather dedicated to create new "lists of" than to customize the TOC. –  lockstep Aug 12 '10 at 13:40
    
Yes, that's the primary function. Though it may be used to replace the standard TOC and lists, and because it's used in KOMA-Script classes its features like \setuptoc can be used to customize the TOC. –  Stefan Kottwitz Aug 12 '10 at 13:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.