Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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...

share|improve this question

1 Answer 1

up vote 7 down vote accepted

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
  \twocolumn[\@makeschapterhead{\centering\contentsname}]%
  \@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}
\addtocontents{toc}{\protect\newpage}
\chapter{Last chapter}
\section{Last section}

\end{document}

Result for report

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}
\addtocontents{toc}{\protect\newpage}
\section{Last section}
\subsection{Last subsection}

\end{document}
share|improve this answer
    
Thanks for such a quick and informative answer. I think it will work. –  annndrey Sep 16 '12 at 11:29
    
Yes, it works!Thanks a lot. –  annndrey Sep 16 '12 at 12:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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