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


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?

-

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.

-
Thank you, worked perfectly fine. –  phimuemue Feb 7 '11 at 12:38
\documentclass{book}
\begin{document}

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

\chapter{foo}
bar

\end{document}

-