Create a contents page using Latex

  • Context: LaTeX 
  • Thread starter Thread starter sara_87
  • Start date Start date
  • Tags Tags
    Latex
Click For Summary

Discussion Overview

The discussion revolves around creating a contents page in LaTeX, specifically how to structure it to include sections and subsections, and how to ensure proper formatting and page numbering.

Discussion Character

  • Homework-related
  • Technical explanation

Main Points Raised

  • One participant seeks guidance on creating a contents page with specific sections and page numbers.
  • Another participant explains that LaTeX automatically generates the table of contents based on the sections defined in the document.
  • It is noted that the page numbers are assigned by LaTeX based on where the sections start in the document, and that typesetting may need to be done twice for the contents to appear correctly.
  • Participants mention that LaTeX provides automatic formatting features, including dots leading to page numbers.

Areas of Agreement / Disagreement

Participants generally agree on how LaTeX handles the creation of a table of contents, but there is no explicit consensus on the best practices for structuring the document to achieve the desired output.

Contextual Notes

There are limitations regarding the control over page numbers and the need for multiple typesetting passes to achieve the correct formatting in the table of contents.

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
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 11 ·
Replies
11
Views
9K
  • · Replies 6 ·
Replies
6
Views
1K
  • · Replies 7 ·
Replies
7
Views
3K
Replies
3
Views
8K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K