Resurchify

It is very easy to generate or create the table of contents in any LaTeX document. LaTeX provides the feature to generate and modify the table of contents automatically without much hard work. It also allows you to change it to a specific style which best suits your requirements. This tutorial teaches you how you can include the table of contents in any LaTeX document.

# Introduction

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 \documentclass{article} \usepackage[utf8]{inputenc} \title{Learn LaTeX} \author{Anup Chaudhari} \date{ } \begin{document} \maketitle \tableofcontents \section{Introduction} This is the Introduction section. This tutorial teaches you how you can include the table of contents in any LaTeX document. \addcontentsline{toc}{section}{First Section} \section*{First Section} This is the First Section of the Tutorial. \section{Second Section} This is the Second Section of the Tutorial. \end{document} 

Generally, the table of contents includes chapters, sections, and subsection. You are also allowed to add entries manually in LaTeX. This is generally done to add the unnumbered sections. To do so, just add the \addcontentsline command, as shown in the above example.

Important Note: Remember in order to make sure that the table of contents works properly, you need to compile your LaTeX document twice.

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 \documentclass{article} \usepackage[utf8]{inputenc} \title{Learn LaTeX} \author{Anup Chaudhari} \date{ } \renewcommand*\contentsname{Tutorials} \begin{document} \maketitle \tableofcontents \section{Introduction} This is the Introduction section. This tutorial teaches you how you can include the table of contents in any LaTeX document. \addcontentsline{toc}{section}{First Section} \section*{First Section} This is the First Section of the Tutorial. \section{Second Section} This is the Second Section of the Tutorial. \end{document}