# Vertical spacing and migration from minitoc to etoc

I've taken over editing a somewhat outdated internal handbook and decided to give etoc a try instead of the previously used minitoc. I'm using the standard LaTeX book class and a regular ToC with only chapters and minitocs for every chapter down to subsubsection. For now I'd like to replicate the old appearance and the configuration was like this:

\documentclass[10pt, a5paper]{book}
% ... other packages and configurations
\usepackage{parskip}
\usepackage[tight]{minitoc}
\setcounter{tocdepth}{0}
\dominitoc
\mtcsetfont{minitoc}{section}{\normalsize\bfseries}
\mtcsetfont{minitoc}{subsection}{\normalsize\rmfamily}
\mtcsetfont{minitoc}{subsubsection}{\normalsize\rmfamily}
\mtcsetdepth{minitoc}{3}
\mtcsettitle{minitoc}{Inhaltsverzeichnis}  % different from \contentsname
\renewcommand{\mtcindent}{0pt}
\begin{document}
% ... titlepage
\tableofcontents
\chapter{Dummy Chapter}\newpage\minitoc\mtcskip
\section{Dummy Section}
\subsection{Dummy Subsection}
% ... more chapters
\end{document}


The next step, inspired by https://tex.stackexchange.com/a/114480/3388

\documentclass[10pt, a5paper]{book}
% ... other packages and configurations
\usepackage{parskip}
\usepackage[titles]{tocloft}
\usepackage{etoc}
\etocchecksemptiness
\etocsettocdepth{subsubsection}
\renewcommand\cftsecfont{\normalfont\bfseries}
\renewcommand\cftsecpagefont{\normalfont\bfseries}
\begin{document}
% ... titlepage
\etocsetnexttocdepth{chapter}
\tableofcontents
\etocarticlestylenomarks
\chapter{Dummy Chapter}\newpage\localtableofcontents
\section{Dummy Section}
\subsection{Dummy Subsection}
% ... more chapters
\end{document}


This way I don't have a custom title for the local ToC, no horizontal lines below the title and the local ToC and, since \section*{\contentsname} is used, varying vertical space around the title. The best I've come up with is:

\newcommand*\localtocname{Inhaltsverzeichnis}  % to separate markup and content
\renewcommand*\etocarticlestylenomarks{%
\etocsettocstyle{%
\large\bfseries\localtocname\\[-0.5\baselineskip]\normalsize\normalfont%
\rule{\linewidth}{\arrayrulewidth}%
}{%
\rule[0.5\baselineskip]{\linewidth}{\arrayrulewidth}%
}%
}


I have no idea concerning vertical space and resorted to cargo cult programming to handle \topskip and stuff, but basically I'd like fixed vertical space from the top of the text area to the title and from the title to the horizontal rule. The vertical space after the rule at the bottom of the local ToC depends on whether there is a paragraph of text or a \section command following, though a consistent minimum space would be nice (unless there is typesetting/design reason against it).

To get an idea, here is a sample from the previous setup:

Here is an emulation. I took your original minitoc example, added \tracingmacros1 then I went to minitoc.sty to locate and copy over suitable macros.

However, at first I think I was throwing out things, but then later I became more faithful.

If I were to start from scratch I would not use this kind of coding.

Only on your full mwe will you be able to judge if faithful to original. In particular I am not sure I have all stuff here related to vertical spacing. (I may edit later if I get time to examine more closely original log).

edit: indeed I forgot \mtcskip from your original code which has meaning {\parskip =\z@ \addvspace {\mtcskipamount }} and \mtcskipamount is \bigskipamount it seems, but its value inside preamble. Thus this should be added here at end of second argument of \etocsettocstyle.

Did I say I would never ever have coded things this way?

\documentclass[10pt, a5paper]{book}
% ... other packages and configurations
\usepackage{parskip}
\usepackage[titles]{tocloft}
\usepackage{etoc}
\etocchecksemptiness
\etocsettocdepth{subsubsection}
\renewcommand\cftsecfont{\normalfont\bfseries}
\renewcommand\cftsecpagefont{\normalfont\bfseries}

\makeatletter
\newcommand*\localtocname{Inhaltsverzeichnis}

% minitoc emulation, macros copied from minitoc.sty
\newcommand*\mtifont{\large \rmfamily \upshape \bfseries }
\newcommand*\mtcfont{\small \rmfamily \upshape \mdseries }

\newlength\mtcindent % 0pt

\newcommand*\mtc@zrule{\rule[\z@]{\z@}{\z@}}
\newcommand*\mtc@BBR{\unpenalty\nopagebreak[4]}
\newbox\mtc@strutbox
\setbox\mtc@strutbox=\hbox{\rule[1.8ex]{\z@}{2.5ex}}
\newcommand*\mtc@strut{\relax\ifmmode\copy\mtc@strutbox
\else\unhcopy\mtc@strutbox\fi}
\newcommand*\mtc@bottom@rule{%
\ifx\mtc@rule\relax\relax\else
\vskip -2.5ex
\rule[2.4\p@]{\columnwidth}{.4\p@}\vspace*{2.6\p@}\fi}

\newcommand*\mtc@verse[1]{\let\\=\@centercr
\list{}{%
\itemsep=\z@ \itemindent=\z@ \partopsep=\z@
\listparindent=\itemindent \topsep=1ex
%\iftightmtc
\parsep=\z@
%\fi
%\ifktightmtc \parskip=\z@ \fi
\leftmargin=\mtcindent \rightmargin=\leftmargin
}%
\item[]}
% I condensed a few macros in this one

\newcommand\do@mtitc[1]{\null \leavevmode \mtc@strut #1\hfill \null}

\newcommand\etocminitocstyle{%
\etocsettocstyle
{%
\begin{samepage}%
\raggedright
\parskip=\z@
\reset@font\mtcfont
\parindent=\z@
\nopagebreak[4]%
\kern-0.8\baselineskip
\nopagebreak[4]%
\par\noindent
\begin{tabular}{@{}p{\columnwidth}@{}}
\reset@font\mtifont\do@mtitc{\localtocname}\\\hline
\end{tabular}%
\nopagebreak[4]%
\null\leavevmode\mtc@zrule\\\mtc@BBR
\leftmargin\mtcindent
\rightmargin\mtcindent
\itemindent=\z@
\labelwidth=\z@
\labelsep=\z@
\listparindent=\z@
\begin{mtc@verse}{0pt}%
\leavevmode\\\mtc@BBR
\vskip -.5\baselineskip
\begingroup
}
{%
\vspace{-1ex}\vspace{-\baselineskip}%
\leavevmode\mtc@strut
\global\@nobreakfalse
\endgroup
\end{mtc@verse}%
\kern -.5\baselineskip \kern .5ex % was \kernafterminitoc
\nopagebreak[4]%
\mtc@bottom@rule\null\leavevmode\\%
\vskip-1.0\baselineskip
\mtc@zrule\end{samepage}%
\par\pagebreak[1]\vspace*{-1ex}%
}%
}
\begin{document}
% ... titlepage
\etocsetnexttocdepth{chapter}
\tableofcontents
\etocminitocstyle
\chapter{Dummy Chapter}\newpage\localtableofcontents
\section{Dummy Section}
\subsection{Dummy Subsection}
% ... more chapters
\end{document}


I think I got the size of Inhaltsverzeichnis wrong, but it is how it came out with minitoc and your MWE. It is not same as in your posted picture.

Ok, so now simply using \etocsettocstyle to handle the title, and the rules. No attempt to emulate anything here.

This code does not influence the rendering of the TOC contents, which are like set by the document class.

\documentclass[10pt, a5paper]{book}
% ... other packages and configurations
\usepackage{parskip}
\usepackage[titles]{tocloft}
\usepackage{etoc}
\etocchecksemptiness
\etocsettocdepth{subsubsection}
\renewcommand\cftsecfont{\normalfont\bfseries}
\renewcommand\cftsecpagefont{\normalfont\bfseries}

\makeatletter
\newcommand*\localtocname{Inhaltsverzeichnis}

\newcommand*\etocmylocaltocglobalstyle {%
\etocsettocstyle {%
\newpage
\if@twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi
\small
\parskip\z@skip
\parindent \z@
{\topskip3cm  % <<<<---- customize
\normalfont\bfseries
\noindent\localtocname
\par
\vskip-.5\baselineskip
}%
}{%
\nobreak\vskip-.5\baselineskip
\bigskip      % <<<<---- customize
\if@restonecol \twocolumn \fi
}%
}
\makeatother

\begin{document}
% ... titlepage
\etocsetnexttocdepth{chapter}
\tableofcontents
\etocmylocaltocglobalstyle
\chapter{Dummy Chapter}
\localtableofcontents
\section{Dummy Section}
\subsection{Dummy Subsection}
% ... more chapters
\end{document}


produces here:

For demonstration, perhaps the vertical spaces are too big.

The stuff about two-column vs one-column is simply copied over from standard book \tableofcontents. As far as I can tell it induces a new page when switching back to two-column, which is not really aesthetic...

• Thanks for the thorough work, though it still seems to involve quite a lot of (low-level) TeXing for a simple fixed vertical space. Also sorry if I wasn't specific enough: I don't need the exact appearance (and you're right, my sample involved more packages), but the basic “fixed distance from top of the page, title with font formatting, and a line directly below and the ToC directly below that” where I can (ideally) adjust the space. In that sense, my request doesn't really depend on etoc or minitoc but more on vertical spacing in general. – pazathoth Oct 29 '17 at 14:27
• @pazathoth yes there is quite low-level thing, but it was not for fixed vertical space (I don't even know it if achieves it), it is only to really emulate minitoc. Now that I read you question better, I will provide more focused answer. The distance you want to control is the one from baseline of title to top of page? – user4686 Oct 29 '17 at 16:21
• oh I remember now the code (in bottom part of answer) which I picked up in some of my files was in context where one wanted to control via leftskip and rightskip some toc margins. This is why \linewidth is not used for the rule width. (but then this was with "linestyles" designed to obey these leftskip/rightskip; here only the rules and the title will, the "linestyles" are inherited from book class and do not) – user4686 Oct 29 '17 at 17:25
• Yes, that's the distance I want to control. I found a related problem (but lost the link to it) and \vspace*{1.5\baselineskip}\vspace{-\topskip}\vspace{-\parskip}% before the title does what I want it to do, though there may be a more elegant version. The 1.5\baselineskip is the part I adjust and any length without glue could be used. After the closing rule I added a simple \\, but that still seems to add a lot more space before a \section than before a paragraph of text. – pazathoth Oct 29 '17 at 17:40
• doesn't simply modifying \topskip3cm achieve the control of top vertical spacing? and regarding the space below bottom rule, it comes from \section , it adds in book class 3.5ex (plus some stretch and shrink) so you can add \vspace{-3.5ex} after the toc before \section but you also need to compensate that the base line will be for \Large, so you need also \vspace{-6pt} because baselineskip is 18pt for Large and 12pt for 10pt font size. I checked with \usepackage[grid]{eso-pic} that adding these two negative spaces work. perhaps the first one \vspace{-3.5explus-1exminus-.2ex} – user4686 Oct 29 '17 at 19:13