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
.
One way to remove the chapter numbering only in the minitoc is to add a command in the section number, which definition will be altered during the minitoc rendering.
Consider the following code to be put in your preamble:
\newcommand{\filterminitoc}[1]{#1}
\renewcommand{\thesection}{\csname filterminitoc \endcsname{\arabic{chapter}.}\arabic{section}}
\newcommand{\minitocsection}{\begingroup\renewcommand{\filterminitoc}[1]{}\minitoc\endgroup}
The first line defines a command that will do nothing, to avoid altering the result outside the minitoc. The second line redefines the section numbering, so that the chapter part of the number is passed to the command \filterminitoc
. The last line defines a new command that will call \minitoc
with a modified command for \filterminitoc
, preventing the rendering of the chapter number.
You can now call \minitocsection
to render the correct minitoc.
Complete code:
\documentclass{book}
\usepackage{minitoc}
\newcommand{\filterminitoc}[1]{#1}
\renewcommand{\thesection}{\csname filterminitoc \endcsname{\arabic{chapter}.}\arabic{section}}
\newcommand{\minitocsection}{\begingroup\renewcommand{\filterminitoc}[1]{}\minitoc\endgroup}
\begin{document}
\dominitoc
\tableofcontents
\chapter{Introduction}
\chapter{chapter two}
\minitocsection
\section{section one}
\section{section two}
\section{section three}
\end{document}
Result:
Best Answer
Answer from 2013
(slightly rearranged for readability, and with a more complete code sample starting with
\documentclass
and ending with\end{document}
)With the etoc package, you generate
minitoc
's with the command\localtableofcontents
. You can modify thetocdepth
counter before this command.It is better (except if intentional) to avoid using
addtocontents
to inscribe sometocdepth
changing instruction to the.toc
file: indeed this will impact all the tables of contents inside the document.Here is the code, to illustrate how one can modify the
tocdepth
counter in the document at the location where the TOCs are inserted.Sorry if I am off-topic as I couldn't tell if
minitoc
was a specific reference to the minitoc package.Update in 2O15
A few months after this answer was posted in 2013,
etoc
got enriched with two new commands\etocsettocdepth
and\etocsetnexttocdepth
.Package
hyperref
takes into account the local value of thetocdepth
counter in its decision of what goes to the bookmarks (but see its optionbookmarksdepth
as documented in itsREADME
). It is thus advisable to use\etocsetnexttocdepth
whose effect extends only to the typesetting of the nextTOC
be it local (\localtableofcontents
) or global.The
\etocsettocdepth{<level>}
should be used once in the preamble or near the beginning of the document to set thetocdepth
counter to a given value. The<level>
may be numeric or a name.The
\etocsetnexttocdepth{<level>}
is for temporarily setting thetocdepth
counter to a value only for the time of typesetting a TOC. This way no impact on the global bookmarks occurs.Here is thus how the code above can be written with
etoc
1.07g [2013/10/13]
or later, in a way which avoids any disturbance of the global hyperref bookmarks: