6

I would like to center the caption of my table of contents, so that it looks as follows:

                         Table of contents 

1.   Section                                              1
1.1  Subsection                                           3
1.2  Subsection                                           5
2    Section                                             11

Instead of

Table of contents 

1.   Section                                              1
1.1  Subsection                                           3
1.2  Subsection                                           5
2    Section                                             11

I've tried to \renewcommand{\contentsname}{\centerline{Table of contents}}, which worked fine for the apperance on the page.

But I'm using a book style where at the top of the page, on the left side, I want to have the name of the current chapter/section/whatsoever. But if I do the above, the text Table of contents is not on the left side, but in the middle (because of the \centerline).

Is there a way to accomplish what I want?

11

There are several package to modify the layout of contents. The simplest one for standard document classes may be tocloft. You can use:

\usepackage{tocloft}
\renewcommand{\cfttoctitlefont}{\hfill\Large\bfseries}
\renewcommand{\cftaftertoctitle}{\hfill}

\tableofcontents is typesetted as \chapter*(for book and report) or \section*(for article). You can modify the layout of chapter(section) titles for table of contents. Thus sectsty or titlesec can be used for standard classes. You can use:

% \documentclass{article}
% \usepackage{sectsty}
\sectionfont{\centering}
\tableofcontents
\sectionfont{}

or

% \documentclass{article}
% \usepackage{titlesec}
\titleformat*{\section}{\centering\bfseries\Large}
\tableofcontents
\titleformat*{\section}{\bfseries\Large}

If you are using classes such as memoir and koma-script, there will be other command for this purpose. You'd better read the manual of these classes.

  • In one context, I had to add a \hspace{0em} after the last \hfill, otherwise the ToC title flushed to the right. – Pedro Sánchez Terraf Apr 19 '16 at 18:00
4
\documentclass{book}
\begin{document}

\makeatletter
\chapter*{\centerline{\contentsname}}
\@mkboth{\MakeUppercase\contentsname}{\MakeUppercase\contentsname}%
\@starttoc{toc}%
\makeatother

\chapter{foo}
bar

\end{document}
2

For me, the only workable solution was

\begin{center}
\tableofcontents
\end{center}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.