3

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

0
6

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)

2
  • OK. '\unsettoc{toc}{twocolumn}' is right way for main TOC. But for TOC per chapter (command '\minitoc') is still formatted in twocolumn layout.
    – JardaFait
    Dec 26 '13 at 10:58
  • 1
    Jafan, you can simply leave \unsettoc{toc}… out, then the default is used. For the minitoc: Yes, I've overseen this, but it would have been better from you, to write more elaborate about your problem. Answer edited.
    – Speravir
    Dec 26 '13 at 19:18

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.