2

I just want a table of contents with two columns by the etoc package. But the following code typesets two TOCs (please see the attached figure). Why? What's wrong with my code?

Code:

\documentclass{article}
\usepackage{etoc}
\usepackage{geometry}
\geometry{showframe}
\geometry{left=1cm,right=1cm,top=1cm,bottom=1cm}
\parindent0pt
\begin{document}
\etocmulticol{}%
\tableofcontents
\section{first}
\subsection{subfirst}
\section{second}
\subsection{subsecond}
\section{third}
\subsection{subthird}
\section{fourth}
\subsection{subfourth}
\section{fifth}
\end{document}

Enter image description here

2
  • 5
    \etocmulticol{} gives you the two-column ToC and \tableofcontents gives you the single-column ToC. You call both macros and therefore you get two ToCs. If you only want the two-column ToC, you need to delete \tableofcontents. May 20 at 6:34
  • 1
    Oh, thanks. I had alway thought that \etocmulticol is only for set not for typeset!
    – lyl
    May 20 at 6:41

2 Answers 2

4

You probably mixed up the macro \etocmulticolstyle with the other macro \etocmulticol. While the first macro is used to set the style for all ToCs that you can then call using tableofcontents, the second macro just directly typesets one ToC styled in the given way without changing the overall style of other ToCs.

So, you should either delete \tableofcontents from your code, or you change \etocmulticol{} to \etocmulticolstyle{}, for example like this:

\documentclass{article}
\usepackage{etoc}
\usepackage{geometry}
\geometry{showframe}
\geometry{left=1cm,right=1cm,top=1cm,bottom=1cm}
\parindent0pt
\begin{document}

\etocmulticolstyle{\textbf{\large Table of Contents}}

\tableofcontents

\section{first}
\subsection{subfirst}
\section{second}
\subsection{subsecond}
\section{third}
\subsection{subthird}
\section{fourth}
\subsection{subfourth}
\section{fifth}
\end{document}

Result:

enter image description here

3

You create two table of contents. One is \etocmulticol, the other one is \tableofcontent. If you comment out one of them, you will get only one.

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.