18

When typesetting an article documentclass, the sections appear as bold in the table of contents, with no leading dots. I would like to change these to non-bold, and insert some leading dots. I tried the following, but it seems to be ignored. Any ideas?

% change section headers and page numbers to normal instead of bold font
\renewcommand{\cftsecfont}{
\normalfont
}
\renewcommand{\cftsecpagefont}{%
\normalfont
}
% use leader dots with section headers
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
lockstep
  • 250,273

2 Answers2

20

Using the tocloft package you can do something like this:

\documentclass{article}
\usepackage{tocloft}

\renewcommand\cftsecfont{\normalfont}
\renewcommand\cftsecpagefont{\normalfont}
\renewcommand{\cftsecleader}{\cftdotfill{\cftsecdotsep}}
\renewcommand\cftsecdotsep{\cftdot}
\renewcommand\cftsubsecdotsep{\cftdot}

\begin{document}

\tableofcontents
\section{test section}
\subsection{test section}
\section{test section}
\subsection{test section}

\end{document}
Gonzalo Medina
  • 505,128
2

The »tocstyle« package from KOMA Script could be an alternative. Note that this package is in alpha state and you'll get a corresponding warning.

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage{babel}
\usepackage{tocstyle}
\usepackage{blindtext}

\begin{document}
  \tableofcontents

  \bigskip
  \Blinddocument
\end{document}

Simply including the package does already what you're after. Further customization is done by declaring new ToC styles. For further information run texdoc tocstyle on the command line.

As always, the blindtext package is only for creating dummy text thus not part of the solution.