# Centering contents name with [twocolumn] contents

I'm trying to make Table of Contents in two columns, but I'd like to center the contents name.

Now I'm doing

\twocolumn
\tableofcontents


but these commands give something like this:

Contents name   section 3
section 1       section 4
section 2       section 5


while I'd like to obtain something like this:

    Contents name
section 1   section 3
section 2   section 4


I cant find out how can I achieve this...

-

Because the documentclass is missing, I give an example for class report and for article. The redefinition for \tableofcontents merges the definitions of the original \tableofcontents with the definition for the environment theindex. The centering is done by smuggling in \centering.

Example for report:

\documentclass[twocolumn]{report}

\makeatletter
\renewcommand*{\tableofcontents}{%
\if@twocolumn
\@restonecolfalse
\else
\@restonecoltrue
\fi
\@mkboth{\MakeUppercase\contentsname}%
{\MakeUppercase\contentsname}%
\thispagestyle{plain}%
\@starttoc{toc}%
\if@restonecol
\onecolumn
\else
\clearpage
\fi
}
\makeatother

\begin{document}
\tableofcontents

\chapter{Foobar}
\section{Hello World}
\subsection{Subsection}
\chapter{Last chapter}
\section{Last section}

\end{document}


Example for article:

\documentclass[twocolumn]{article}

\makeatletter
\renewcommand*{\tableofcontents}{%
\if@twocolumn
\@restonecolfalse
\else
\@restonecoltrue
\fi
\twocolumn[\section*{\centering\contentsname}]%
\@mkboth{\MakeUppercase\contentsname}%
{\MakeUppercase\contentsname}%
\thispagestyle{plain}%
\@starttoc{toc}%
\if@restonecol
\onecolumn
\else
\clearpage
\fi
}
\makeatother

\begin{document}
\tableofcontents

\section{Foobar}
\subsection{Hello World}
\subsubsection{Subsubsection}