Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Create a contents page using Latex

  1. Dec 30, 2009 #1
    1. The problem statement, all variables and given/known data

    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.

    2. Relevant equations



    3. 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
     
  2. jcsd
  3. Dec 31, 2009 #2

    cepheid

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Re: latex

    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 (Text):
    \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:
     
  4. Dec 31, 2009 #3
    Re: latex

    Thank you very much.
    It's working now :)
     
  5. Dec 31, 2009 #4

    diazona

    User Avatar
    Homework Helper

    Re: latex

    I might add that LaTeX is very smart in that respect.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook