# Customize minitoc

I'm writing my thesis and I woud like to add a minitoc at the beginning of each chapter. However, I don't like the standard format where the titles of the sections are listed as in the main TOC and I would like to align the titles on the same row (a format I saw in several books), maybe sperated by a comma or a textbullet. I mean something like this:

Chapter 1

Contents

1.1 Sec 1, 1.2 Sec 2, 1.3 Sec3, 1.4 Sec 4

I can do this for the main TOC through the titletoc package, but I need it for minitoc. Is there a way to have this customization of the minitoc? Thank you in advance.

-
Would using titletoc for the partial ToC (instead of minitoc) also be an option? –  Gonzalo Medina May 17 '12 at 20:48

Here's one possible solution using titletoc for both the main and the partial ToCs; the titlesec package was also used so that \chapter will start and print its partial ToC automatically:

\documentclass{book}
\usepackage{titlesec}
\usepackage{titletoc}

\newcommand\partialtocname{\contentsname}

\begin{document}

\tableofcontents

\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
[\vspace*{2pc}\titlerule\vspace*{1pc}%
\startcontents\vbox{\Large\partialtocname}\vskip1ex
\printcontents{l}{1}{\setcounter{tocdepth}{1}}\vspace*{1pc}\titlerule]
\titlecontents*{lsection}[0pt]
{\small\normalfont}{\thecontentslabel\space}{}
{,~\itshape\thecontentspage}[\space\textbullet\space][.]
\titlecontents*{lsubsection}[0pt]{}{}{}{}

\chapter{Chapter One}
\section{Section One One}
\subsection{Subsection One One One}
\subsection{Subsection One One Two}
\section{Section One Two}
\subsection{Subsection One Two One}
\subsection{Subsection One Two Two}
\section{Section One Three}
\subsection{Subsection One Three One}
\subsection{Subsection One Three Two}

\chapter{Chapter Two}
\section{Section Two One}
\subsection{Subsection TwoOne One}
\subsection{Subsection Two One Two}
\section{Section Two Two}
\subsection{Subsection Two Two One}
\subsection{Subsection Two Two Two}

\end{document}

The main ToC:

The partial ToCs:

and

Of course, your thesis will have some chapters that won't require a partial ToC such as those of the front and backmatter sections (Acknowledgements, Preface, Main ToC, possibly Appendices and the Bibliography). I did a improvement to my initial code defining a boolean to let you easily activate and deactivate the partial ToCs; initially the boolean is set to false, so the frontmatter chapters won't have partial ToCs; once you begin the mainmatter (in fact, whenever you want to start using partal ToCs) all you have to do is to set the boolean to true using \chapterwithtoctrue. For the backmatter (or, in general, to deactivate the partial ToCs) all you have to do is to set the boolean to false using \chapterwithtocfalse; a complete example:

\documentclass{book}
\usepackage{titlesec}
\usepackage{titletoc}

% The name to be used as title for the partialToCs
% initially set to be equal to \contentsname
\newcommand\partialtocname{\contentsname}
% depending on this boolean, \chapter will create or not a partial ToC
\newif\ifchapterwithtoc
\chapterwithtocfalse

\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
[\ifchapterwithtoc
\vspace*{2pc}\titlerule\vspace*{1pc}%
\startcontents\vbox{\Large\partialtocname}\vskip1ex
\printcontents{l}{1}{\setcounter{tocdepth}{1}}\vspace*{1pc}\titlerule%
\else\fi%
]

\titlecontents*{lsection}[0pt]
{\small\normalfont}{\thecontentslabel\space}{}
{,~\itshape\thecontentspage}[\space\textbullet\space][.]
\titlecontents*{lsubsection}[0pt]{}{}{}{}

\begin{document}

\frontmatter
\chapter*{Acknowledgements}
\chapter*{Preface}
\tableofcontents

\mainmatter
\chapterwithtoctrue

\chapter{Chapter One}
\section{Section One One}
\subsection{Subsection One One One}
\subsection{Subsection One One Two}
\section{Section One Two}
\subsection{Subsection One Two One}
\subsection{Subsection One Two Two}
\section{Section One Three}
\subsection{Subsection One Three One}
\subsection{Subsection One Three Two}

\chapter{Chapter Two}
\section{Section Two One}
\subsection{Subsection TwoOne One}
\subsection{Subsection Two One Two}
\section{Section Two Two}
\subsection{Subsection Two Two One}
\subsection{Subsection Two Two Two}

\backmatter
\chapterwithtocfalse

\chapter{Appenix One}
\chapter{Appenix Two}

\end{document}

This can be improved even more by appropriately patching (wuth the help of the etoolbox package, for example) \frontmatter, \mainmatter and \backmatter.

-
Thank you very much for your great reply! However I noticed a small problem when I have several subsections. Infact, in this case there seems to be addictional space between the page number and the following textbullet. Moreover the more subsection I have the larger this space seems to be. Is there a way to solve this problem? –  Marco May 18 '12 at 9:03
@Marco Please, if you consider that my answer solved you problem, mark it as accepted (in case of doubt, please see How do you accept an answer?). The problem has now been solved; all that was required was an (empty) definition of the format for subsection entries; please see my updated answer. –  Gonzalo Medina May 18 '12 at 13:01