Centering table of contents caption

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.


\documentclass{book}
\begin{document}

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

\chapter{foo}
bar

\end{document}

For me, the only workable solution was

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