LaTeX Create a contents page using Latex

  • Thread starter Thread starter sara_87
  • Start date Start date
  • Tags Tags
    Latex
Click For Summary
To create a contents page in LaTeX, use the command \tableofcontents, which automatically generates a table of contents based on the sections and subsections defined in the document. To include items, you must add sections using commands like \section and \subsection. LaTeX assigns page numbers based on where these sections appear in the document, so the actual page number may vary depending on the content. Additionally, LaTeX generates dots leading to page numbers on the right side of the table of contents. For the contents to display correctly, it may be necessary to compile the document twice. LaTeX's typesetting system differs from traditional word processors, as it automates much of the formatting and layout based on the code provided.
sara_87
Messages
748
Reaction score
0

Homework Statement



I want to create a contents page using Latex.
Say I want the first link to be Statistics which is on page 1 then a sublink called estimators which is on page 3.

Homework Equations





The Attempt at a Solution


\tableofcontents
\setcounter{tocdepth}{2}

Then I'm stuck. how do i go on from here. also, how do i make dots all the way from the title to the page number column?

Thank you
 
Physics news on Phys.org


Hi sara_87

When you type in the \tableofcontents control sequence, LaTeX automatically creates a table of contents whose items are based upon what sections you have in your document. That is to say, you do not manually add items to the table of contents, LaTeX does it for you. If you want items to appear in the table of contents, you have to add sections to your document. For example, try the following. I have included a barebones example LaTeX source file with an (empty) document preamble below:

Code:
\documentclass{article}

\begin{document}

\tableofcontents

\section{Statistics}
\subsection{Estimators}
\end{document}

Notes:

1. You don't control what page your section appears on. LaTeX checks the page on which your section starts in the document and assigns a page number in the table of contents accordingly. In this empty test document, since both sections are empty and therefore start on page 1, LaTeX will assign page 1 to both of them in the table of contents.

2. LaTeX automatically creates the list of items with dots leading to page numbers on the right hand side.

3. To get the stuff in #2 to appear, you'll probably have to typeset the document twice in a row.

LaTeX typesetting is not at all like word processing. You enter some simple lines of code, and LaTeX does the vast majority of formatting and layout automatically based upon how it thinks things should be placed. That is the point. :wink:
 


Thank you very much.
It's working now :)
 


cepheid said:
LaTeX typesetting is not at all like word processing. You enter some simple lines of code, and LaTeX does the vast majority of formatting and layout automatically based upon how it thinks things should be placed. That is the point. :wink:
I might add that LaTeX is very smart in that respect.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 11 ·
Replies
11
Views
8K
  • · Replies 6 ·
Replies
6
Views
1K
  • · Replies 7 ·
Replies
7
Views
2K
Replies
3
Views
7K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K