3

I would like to center PART and wrap the subsubsection in one line in TOC, with proper indentation (matching with section or subsection or chapter). Please see the image. Attached is the sample code too. Thank you very much.

Sample Current Output

\documentclass[12pt,bothside]{book}


\usepackage[titles]{tocloft}% 
\renewcommand{\cftchapleader}{~\cftdotfill{5}}
\setcounter{secnumdepth}{0}
\setcounter{tocdepth}{3}

% to center part
\renewcommand{\cftpartfont}{\hfill\Large\bfseries}
\renewcommand{\cftpartaftersnum}{\hfill}
\addtocontents{toc}{\cftpagenumbersoff{part}}

%wrap TOC contents
\usepackage{titletoc}
\titlecontents*{subsubsection}% <section>
  [1.5em]% <left>
  {\scriptsize}% <above-code>
  {}% <numbered-entry-format>
  {}% <numberless-entry-format>
  {,\ \thecontentspage}% <filler-page-format>
  [\ - \ ]% <separator>
  [\\]% <end>


\begin{document}

\frontmatter
\tableofcontents

\mainmatter
\part{Part 1}
\chapter{Chapter1}
\section{Section 1}
\subsubsection{Subsubsection 1}
\subsubsection{Subsubsection 2}


\part{Part 2}
\chapter{Chapter1}
\section{Section 1}
\subsection{Subection 1}
\subsubsection{Subsubsection 1}
\subsubsection{Subsubsection 2}


\end{document}
1

As the documentation for tocloft says, in standard classes (such as book) \cftpartaftersnum has no effect. Instead you can patch the generating command for this entry, \l@part, adding extra code to the instance #1, where the title is inserted, to add the filling from the right (and to remove a fixed space to the right).

\usepackage{xpatch}
\makeatletter
\patchcmd{\l@part}{#1}{#1\hfill\hskip-\rightskip\mbox{}}{}{}
\makeatother

Note the solutions given at Center parts in toc with tocloft do not work when the page number of the part is suppressed.

For the subsubsection I think you must just choose one indentation amount. I suggest making it so it fits under sections or indenting further to its own alignment.

Sample output

\documentclass[12pt,twoside]{book}

\usepackage[titles]{tocloft}%
\renewcommand{\cftchapleader}{~\cftdotfill{5}}
\setcounter{secnumdepth}{0}
\setcounter{tocdepth}{3}

% to center part
\renewcommand{\cftpartfont}{\hfill\Large\bfseries}
\usepackage{xpatch}
\makeatletter
\patchcmd{\l@part}{#1}{#1\hfill\hskip-\rightskip\mbox{}}{}{}
\makeatother
\addtocontents{toc}{\cftpagenumbersoff{part}}

%wrap TOC contents
\usepackage{titletoc}
\titlecontents*{subsubsection}% <section>
  [3.8em]% <left>
  {\scriptsize}% <above-code>
  {}% <numbered-entry-format>
  {}% <numberless-entry-format>
  {,\ \thecontentspage}% <filler-page-format>
  [\ - \ ]% <separator>
  [\\]% <end>

\begin{document}
\showoutput
\frontmatter
\tableofcontents

\mainmatter
\part{Part 1}
\chapter{Chapter1}
\section{Section 1}
\subsubsection{Subsubsection 1}
\subsubsection{Subsubsection 2}


\part{Part 2}
\chapter{Chapter1}
\section{Section 1}
\subsection{Subection 1}
\subsubsection{Subsubsection 1}
\subsubsection{Subsubsection 2}


\end{document}
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.