Headings and Table of Contents

Now let’s see how to set headings and the table of contents. XeLaTeX has the ability to automatically number your headings and to create a table of contents that updates whenever you do changes in theĀ headings of the document. According to the document class you are using, certain heading types are available to use: the headings for the article class (remember, we set \documentclass{article}) are \section,\subsection and \subsubsection. The classes report, book and memoir have also \chapter and \part. Let’s see an example of headings use in the document.

headings

 

The commands for the headings are, respectively, \section{}, \subsection{} and \subsubsection{}. What you put inside the curly brackets will be the actual heading of that section. Numbering is automatic and it automatically updates if you change the order of your sections. Moreover, the structure panel on the left shows the structure of your document using the section headings that you have defined with the above commands. This is very handy if you have a big document and you want to easily switch from one section to the other.

Now that we know how to head sections and headings, we can typeset a table of contents: the command for it is, simply enough, \tableofcontents. You have to insert it inside the document environment, in the place where you want your table of contents to appear (generally at the beginning of your document, i.e. just after\maketitle). You’ll probably need to typeset twice before actually seeing the table of contents in your compiled document.

tableofcontents