How to make a table of contents like this? I tried minitoc but the output is completely different, also, I can't find commands to make my table of contents like this. For example, removing the section number, removing the dots between the page number and the section name.

\documentclass[a4paper,10pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[margin=1in]{geometry}
\usepackage{palatino}
\usepackage{multicol}
\usepackage{minitoc}

\begin{document}
\dominitoc
\nomtcrule
\tableofcontents
\chapter{Introduction}
\begin{multicols}{2}
\minitoc
test
\vfill
\columnbreak
test2
\end{multicols}
\section{blubb}

\section{foo}
\end{document}

• Take a look at etoc. It gives you complete control. – cfr Sep 25 '16 at 22:32
• This is sufficiently different from any normal table of contents that you might consider writing a custom macro. OTOH, creating a table of contents is a three step process. First each chapter, section and subsection writes an entry into the aux file. The next time \tableofcontents runs it creates the toc file. Finally the toc file is used to create the actual table of contents. – John Kormylo Sep 25 '16 at 22:33

Here's an example using etoc. It is designed to keep the \localtableofcontents local to where it is issued via \begingroup and \endgroup. I also put the option twocolumn in the \documentclass call for the convenience of this example, not because I think you necessarily should construct your document that way.

The key command in all of this is \etocsetstyle, which takes five mandatory arguments. (See §.4.1 in the manual.)

\documentclass[twocolumn, a4paper,10pt, openany]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[margin=1in]{geometry}
\usepackage{palatino}
\usepackage{etoc, soul, lipsum}

\newcommand\mylocaltableofcontents{%
\begingroup
\etocsettocstyle{\par\noindent \large \contentsname \par\nobreak\bigskip}{}
\renewcommand*{\contentsname}{\ul{Contents}}
\setcounter{secnumdepth}{2}
\etocsettocdepth{2}

\etocsetstyle{section}
{\par\noindent}
{\normalsize\rmfamily}
{\par\noindent}

\etocsetstyle{subsection}
{\par\noindent}
{\normalfont\hspace*{2em}}
{\par\noindent}

\localtableofcontents
\endgroup
}

\begin{document}
\tableofcontents

\chapter{Introduction}
\section{Baz}
\subsection{Bar}
\subsubsection{Foo}
\section{Baz}
but the output is completely different, also, I can't find commands
\subsubsection{Foo}
\section{Baz}
\subsection{Bar}
\subsubsection{Foo}
\section{Baz}
\subsection{Bar}
\subsubsection{Foo}

\lipsum

\chapter{Introduction}

\mylocaltableofcontents

\section{Baz}
\subsection{Bar}
\subsubsection{Foo}
\section{Baz}
but the output is completely different, also, I can't find commands
\subsubsection{Foo}
\section{Baz}
\subsection{Bar}
\subsubsection{Foo}
\section{Baz}
\subsection{Bar}
\subsubsection{Foo}

\lipsum

\chapter{Introduction}

\localtableofcontents

\section{Baz}
\subsection{Bar}
\subsubsection{Foo}
\section{Baz}
but the output is completely different, also, I can't find commands
\subsubsection{Foo}
\section{Baz}
\subsection{Bar}
\subsubsection{Foo}
\section{Baz}
\subsection{Bar}
\subsubsection{Foo}

\lipsum

\end{document}


The result looks like this (nothing else is customized):

• you can use \etocsetnexttocdepth{2} because \etocsettocdepth{2} is like \setcounter{tocdepth}{2} hence has permanent effect (even within \begingroup...\endgroup). And hyperref looks at value of tocdepth counter for the pdf bookmarks. Hence with \etocsetnexttocdepth{2} or \etocsetnexttocdepth{subsection} you are sure not to impact hyperref. – user4686 Sep 26 '16 at 6:56
• the problem with using a \parbox is that you will have uneven line spacing depending on presence of descenders in last line inside the parbox (or first line should always have big letter anyhow). You can do things like storing the \prevdepth after a final \par inside the \parbox, and reassigning it after the \parbox... but if that looks scary you can also simply use \leftskip technique (like actually LaTeX's own code does for its tables of contents). Or simply perhaps add a bit more vertical space before and after the \parbox (it is "centered" as you did not use [t] or [b]). – user4686 Sep 26 '16 at 7:02
• I get "Package multicol Warning: May not work with the twocolumn option on input line 150." if I put the option twocolumn in the \documentclass call, How to solve this problem? – fairytale Sep 26 '16 at 8:05
• Forget to say, I removed everything about multicol package but I still get this "Package multicol Warning". – fairytale Sep 26 '16 at 8:43
• @jfbu -- Will edit. First real time using package ... always mean to try it out, but never seem to get around to it. This question was the spur since it seemed like a fairly simple request. etoc provides a lot of commands..! – jon Sep 26 '16 at 17:45