1

I have two question regarding toc in book class.

First, I added list of table to contents using:

\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{\listtablename}

It appears in contents. However, there is no dots filling the gap between the title and page number. How to add dots for this, please?

Second, how do I add the contents itself to the contents itself, please?

Thank you!

  • Use tocbibind package \usepackage{tocbibind}. Donts don't appear as toc is put as a chapter. If you need dots then use tocloft package. – user11232 Oct 19 '15 at 0:47
  • @HarishKumar Thanks for commenting. Could you give a bit more details, please? – LaTeXFan Oct 19 '15 at 0:52
  • @HarishKumar The tocbibind worked. But still not dots. Where and how to use tocloft, please? – LaTeXFan Oct 19 '15 at 0:55
  • I have added an answer. – user11232 Oct 19 '15 at 1:23
  • I'm still asking myself what can be the reason for listing the table of contents in the table of contents. ;-) – egreg Oct 19 '15 at 6:56
2

For adding contents in toc, just add \usepackage{tocbibind} in your preamble. To put dots for contents, load tocloft package and issue \renewcommand \cftchapdotsep{4.5}

\documentclass{book}
\usepackage{blindtext}
\usepackage{tocbibind}
\usepackage{tocloft}
 \renewcommand \cftchapdotsep{4.5}
\begin{document}
  \tableofcontents
  \Blinddocument
\end{document}

enter image description here

Here is a variant using titlesec instead of fncychap

\documentclass[draft]{book}
\usepackage{blindtext}
\usepackage{tocbibind}
\usepackage[titles]{tocloft}
\renewcommand \cftchapdotsep{4.5}

 \usepackage{titlesec}
 \titleformat{\chapter}[display]
    {\filcenter\bfseries\Large}
    {\MakeUppercase{\chaptertitlename} \Huge\thechapter}
    {4ex}
    {\titlerule
        \vspace{2ex}%
    }
    [\vspace{2ex}%
        \titlerule] 
    %
    \titleformat{name=\chapter,numberless}[display]
    {\filcenter\bfseries\Large}
    {}
    {4ex}
    {\titlerule
        \vspace{2ex}%
    }
    [\vspace{2ex}%
        \titlerule]
    \titlespacing*{\chapter} {0pt}{0pt}{40pt}
    \titlespacing*{name=\chapter,numberless} {0pt}{15pt}{40pt}
\begin{document}
  \tableofcontents
  \Blinddocument
\end{document}
  • Thanks. It is cool. But it will mess up with my preferred title font as in \usepackage[Sonny]{fncychap}; \ChNameVar{\centering\Large\bfseries}; \ChTitleVar{\centering\Large\bfseries}. Is there a fix to this, please? – LaTeXFan Oct 19 '15 at 1:38
  • @LaTeXfan Try with \usepackage[titles]{tocloft}. However, it is better not to use fncychap, use titlesec instead and format the titles. – user11232 Oct 19 '15 at 1:51
  • \usepackage[titles]{tocloft} worked even with fncychap. Brilliant! Thank you! How and where did you learn this stuff, please? – LaTeXFan Oct 19 '15 at 3:28
  • @LaTeXfan: I have added a titlesec variant. – user11232 Oct 19 '15 at 4:57

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.