[Tex/LaTex] KOMA-Script: Table of Contents in Two Columns

koma-scripttable of contentstocbasictwo-column

I have a document in two column mode. All works fine (all in two columns) — except the table of contents (toc). Strangely I found a solution:

\unsettoc{toc}{onecolumn}

This leads to a toc in two columns?! I do not understand since it says
literally onecolumn in the command.

enter image description here (screenshot; taken from the manual)

\documentclass[
    twoside = false,
    twocolumn = true,
    listof=totoc,
    ]{scrbook}

% Comment in/out to see effect
\unsettoc{toc}{onecolumn}

\begin{document}

\tableofcontents

\chapter{Chapter}
Test

\section{Section}
Test

\subsection{SubSection}
Test

\subsubsection{SubSubSection}
Test

\paragraph{Paragraph}
Test

\subparagraph{SubParagraph}
Test

\end{document}

\unsettoc{toc}{onecolumn} active

enter image description here

\unsettoc{toc}{onecolumn} NOT active

enter image description here

After the Solution

Be aware that there is a UNset (unsettoc) command and set (setuptoc) command. I didn't read carefully enough!

Best Answer

While the command \setuptoc{<extension>}{<feature list>} sets the features for an file extension like toc or lof, the command \unsettoc{<extension>}{<feature list>} unsets the listed features. Note that these are tocbasic commands and the file extension must be controlled by package tocbasic.

Each of the KOMA-Script classes scrartcl, scrreprt and scrbook loads package tocbasic and their ToC and the default lists are controlled by tocbasic automatically. scrreprt and scrbook also set the feature onecolumn for the TOC and the lists of owner float as default. So if you do not want a onecolumn TOC with scrreprt or scrbook you have to use

\unset{toc}{onecolumn}

to deactivate the onecolumn feature for the TOC.

If the lists (controlled by tocbasic) should alse be twocolumn, you can use

\makeatletter
\doforeachtocfile{\unsettoc{\@currext}{onecolumn}}
\makeatother

listof=totoc is an option of the KOMA-Script classes which does the same as

\makeatletter
\doforeachtocfile[float]{\setuptoc{\@currext}{totoc}}
\makeatother

So it effects only lists of the owner float like lof or lot and not toc. Note that an entry of the TOC in the TOC is not recommended. But it is possible with

\setuptoc{toc}{totoc}

enter image description here

enter image description here

Code:

\documentclass[
    twoside = false,
    twocolumn = true,
    listof=totoc,
    ]{scrbook}

\setuptoc{toc}{totoc}

\makeatletter
\doforeachtocfile{\unsettoc{\@currext}{onecolumn}}
\makeatother

\begin{document}

\tableofcontents
\listoffigures
\chapter{Chapter}
Test
\section{Section}
Test
\subsection{SubSection}
Test
\subsubsection{SubSubSection}
Test
\paragraph{Paragraph}
Test
\subparagraph{SubParagraph}
Test
\captionof{figure}{A Figure}
\end{document}
Related Question