How can I do a boxed minitoc at the beginning of any chapter like this.
It is too hard for me.
minitoc
How can I do a boxed minitoc at the beginning of any chapter like this.
It is too hard for me.
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
.
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 the tocdepth
counter before this command.
It is better (except if intentional) to avoid using addtocontents
to inscribe some tocdepth
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.
\documentclass{book}
\usepackage{etoc}
\begin{document}
\setcounter{tocdepth}{2}% down to subsections in main TOC
\tableofcontents
% redefine the headings of the future TOCs to use \section* rather than \chapter*
\etocarticlestyle
\chapter{Vincere}
\setcounter{tocdepth}{1}% local TOC displays only sections
\localtableofcontents
\section {Section 1}
\subsection {1.a}
\subsection {1.b}
\section {Section 2}
\subsection {2.a}
\subsection {2.b}
\chapter{Vincere ancora}
\setcounter{tocdepth}{2}% local TOC again displays sections and subsections
\localtableofcontents
\section {Section 3}
\subsection {3.a}
\subsection {3.b}
\section {Section 4}
\subsection {4.a}
\subsection {4.b}
\end{document}
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 the tocdepth
counter in its decision of what goes to the bookmarks (but see its option bookmarksdepth
as documented in its README
). It is thus advisable to use \etocsetnexttocdepth
whose effect extends only to the typesetting of the next TOC
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 the tocdepth
counter to a given value. The <level>
may be numeric or a name.
The \etocsetnexttocdepth{<level>}
is for temporarily setting the tocdepth
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:
\documentclass{book}
\usepackage{etoc}
\usepackage{hyperref}% for testing
\begin{document}
\etocsettocdepth{subsection}
% the main TOC goes down to subsections, and the bookmarks too.
\tableofcontents
% redefine the headings of the TOCs to use \section* rather than \chapter*
\etocarticlestyle
\chapter{Vincere}
\etocsetnexttocdepth{section}
% this local TOC goes down to sections, there is nil impact on bookmarks
\localtableofcontents
\section {Section 1}
\subsection {1.a}
\subsection {1.b}
\section {Section 2}
\subsection {2.a}
\subsection {2.b}
\chapter{Vincere ancora}
% this local TOC again displays down to subsections, like the main TOC
\localtableofcontents
\section {Section 3}
\subsection {3.a}
\subsection {3.b}
\section {Section 4}
\subsection {4.a}
\subsection {4.b}
\end{document}
Best Answer
Here's one possibility:
The general ToC:
The partial ToC for chapter one:
The partial ToC for chapter two:
Remarks
titlesec
was used to change the formatting for the chapter headings.titletoc
was used to produce the partial ToCs.tcolorbox
was used to produce the frame and title around the partial ToCs.