[Tex/LaTex] KOMA-Script (scrbook): onecolumn table of contents & minitoc in twocolumn document

koma-scriptminitocscrbooktable of contentstwo-column

I have problem with formatting of my tables of contents. Please see my MNWE below. I would like to switch all of my tables into one column layout. I try to use solution from this tex.stackexchange answer, which use this peace of the tex code:

\unsettoc{toc}{onecolumn} 

but it seems, that doesn't work. I tried to understand manual scrbook (page 264), but unfortunately I did not get it. I use miktex/xelatex. I attach also pictures the result of translation.

\documentclass[twocolumn]{scrbook}
\usepackage[nohints]{minitoc}  
\unsettoc{toc}{onecolumn}
\usepackage{lipsum}
\begin{document}
\dominitoc
\tableofcontents
\chapter{Foo}
\minitoc
\lipsum[1]
\section{Bar}
\lipsum[2]
\subsection{Baz}
\lipsum[3]
\section{FooBarBaz}
\lipsum[4]
\end{document}

enter image description here
figure 1: Command \tableofcontents


enter image description here
figure 2: Command \minitoc

Best Answer

For the main toc

Please read carefully again the linked answer and the KOMA-Script documentation1): By default in scrbook (and scrreprt) the toc is set in onecolumn modus. Only, when you want to have it in two columns, you need \unsettoc{toc}{onecolumn}. So, leaving it out is the solution here …

For the minitoc

Use \setchapterpreamble2). Note, you must set it before the chapter, where it belongs to. With two optional arguments you can influence position and width.

Also take notice, that I had to deactivate the rules before and after with \mtcsetrules{minitoc}{off}. As workaround I added two times \hrulefill (the first must be in \smash and then a make box [it would have worked without, but then a more difficult vertical space determining], the second would also work without, but I just copied it) and some vertical spaces. I guess, the \vspace must be individually adjusted to one’s font and font size.

Since you very probably will have more than one chapter, I defined two new commands, see below code for remarks. Because these have \setchapterpreamble inside (or are intended to use them inside), these must be set before each chapter.

\documentclass[twocolumn]{scrbook}
\usepackage[nohints]{minitoc}
\mtcsetrules{minitoc}{off}
\usepackage{lipsum}

\newcommand{\dochaptertoc}{%
  \vspace{1.85\baselineskip} % workaround for removed rule
  \smash{\makebox[\linewidth]{\hrulefill}} % workaround for removed rule
  \vspace{-1.85\baselineskip} % workaround for removed rule
  \minitoc
  \vspace{-1.15\baselineskip} % workaround for removed rule
  \smash{\makebox[\linewidth]{\hrulefill}} % workaround for removed rule
  \vspace{1.15\baselineskip} % workaround for removed rule
}
\newcommand{\setchaptertoc}{%
  \setchapterpreamble{% KOMA-Script command
    \dochaptertoc%
  }}

\begin{document}
\dominitoc
\tableofcontents

\setchaptertoc
\chapter{One}
\lipsum[1]
\section{One, one}
\lipsum[2]
\subsection{One, one, one}
\lipsum[3]
\section{One, two}
\lipsum[4]

\setchapterpreamble{
  \dictum{Time for a bon-mot.}% KOMA-Script command
  \dochaptertoc
}
\chapter{Two}
\lipsum[5]
\section{Two, one}
\lipsum[6]
\section{Two, two}
\subsection{two, two, one}
\lipsum[7]
\end{document}

In most cases it will be enough to put \setchaptertoc in front of a chapter. But for cases, when you want to add more than the minitoc, I defined \dochaptertoc with the workarounds for removed rules intended for use in \setchapterpreamble, cf. chapter 2 in the example.

1) Read online on Texdoc.net: “\setuptoc” & “\unsettoc” (PDF)

2) Read online on Texdoc.net, as well: “\setpartpreamble” & “\setchapterpreamble” (PDF again)