Was this tutorial helpful?

How to Create a Clickable Table of Contents in LaTeX?

In LaTeX, a table of contents helps organize long documents, but the default one is not clickable.

Many learners get confused when they want modern PDF-style navigation with links.

This tutorial will guide you through different methods to create a clickable table of contents and also customize its look if needed.

Table of Contents

The simplest way to add a TOC is to use the \tableofcontents command. It creates a list of all sections, subsections, and chapters automatically.

\tableofcontents
  • \tableofcontents

    Generates the TOC for your document. It automatically collects all sectioning commands like \chapter, \section, and \subsection that you have used.

    Each entry is listed with its page number, so readers can quickly find where a topic starts.

    The format of the table can be customized using packages such as tocloft or titletoc.

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\tableofcontents

\section{Introduction}
  \lipsum[1]
\subsection{Background}
  \lipsum[2]
\end{document}

Using hyperref Package for Clickable TOC

If you want your table of contents entries to be clickable in PDF, you need the hyperref package.

This package turns section names, references, citations, and TOC items into active links.

\usepackage[colorlinks=true, linkcolor=blue]{hyperref}
  • \usepackage{hyperref}

    This package enables hyperlinks throughout the document, including TOC entries, references, and cross-references.

  • colorlinks=true

    This option makes links colored instead of boxed. It is useful for a cleaner look.

  • linkcolor=blue

    This sets the color of internal links (like TOC entries). You can change it to red, green, or any other supported color.

\documentclass{article}

\usepackage[colorlinks=true, linkcolor=blue]{hyperref}
\usepackage{lipsum}

\begin{document}
\tableofcontents

\section{Introduction}
  \lipsum[1][1-2]
\subsection{Motivation and Objectives}
   \lipsum[2][1-2]
\section{Background and Literature Review}
   \lipsum[3][1-2]
\subsection{Related Work and Theories}
   \lipsum[4][1-3]
\section{Conclusion}
\lipsum[5][1-3]

\end{document}

Customizing TOC with tocloft

If you want to change spacing, fonts, or styles in TOC but still keep links, you can combine tocloft with hyperref.

\renewcommand{\cfttoctitlefont}{\Large\bfseries}
\renewcommand{\cftsecfont}{\bfseries}
\renewcommand{\cftsecpagefont}{\itshape}
  • \cfttoctitlefont

    Redefines the font style of the TOC title. Here it is set to be large and bold.

  • cftsecfont

    Changes the font style of section entries in the TOC. They will appear in bold text.

  • \cftsecpagefont

    Alters the font style of section page numbers in the TOC. They will be shown in italics.

\documentclass{report}
\usepackage[colorlinks=true, linkcolor=blue]{hyperref}
\usepackage{tocloft}

\usepackage{lipsum}

\renewcommand{\cfttoctitlefont}{\Large\bfseries}
\renewcommand{\cftsecfont}{\bfseries}
\renewcommand{\cftsecpagefont}{\itshape}

\begin{document}
\tableofcontents

\section{Introduction}
   \lipsum[1]
\section{Overview}
   \lipsum[2]
\end{document}

Best Practice

For most cases, using hyperref with \tableofcontents is enough, since it makes all TOC entries clickable without extra setup.

If you want more style customization, then add tocloft package.


Note: In this tutorial, the \lipsum command is used only to insert dummy text so that the compiled output does not look empty.

It is basically a Lorem Ipsum generator, useful for learning and testing, but in your real document you should replace it with your own content.

Was this tutorial helpful?

Share tutorial

Leave a Comment

Your email address will not be published. Required fields are marked *