Create a contents page using Latex

  • Context: LaTeX 
  • Thread starter Thread starter sara_87
  • Start date Start date
  • Tags Tags
    Latex
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 2K views
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.