Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is it possible with LaTeX commands, or a LaTeX package, to format the Table Of Contents (TOC) of a book so that the TOC looks like this :


Table des matières

Chapter I - MyChapter1

I.1 MySection1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  1

I.1.1 MySubSection1 (1).

I.2 MySection2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  3

I.2.1 MySubSection1 (3). I.2.2 MySubSection2 (9)I.2.3 MySubSection3 (11). 
I.2.4 MySubSection4 (12).


Chapter II - MyChapter2

II.1 MySection1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

II.1.1 MySubSection1 (12)

II.2 MySection2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

II.2.1 MySubSection1 (12). II.2.2 MySubSection2 (13).II.2.3 MySub
Section3 (15). II.2.4 MySubSection4 (16). II.2.5 MySubSection5 
(17). II.2.6 MySubSection6 (18).II.2.7 MySubSection7 (21). II.2.8 
MySubSection8 (27).II.2.9 MySubSection9 (40). II.2.10 MySubSection
10 (45).II.2.11 MySubSection11 (46). II.2.12 MySubSection12 (53). 
II.2.13 MySubSection13 (54). II.2.14 MySubSection14 (58).

So that :

  • Each chapter title is displayed with the prefix "Chapter " and no reference to the page of the book.

  • Each Section is shown with the reference on the right of the toc to the book page and separated with some "...."

  • The list of subsection is displayed as ()...

(note: numbering issues are already solved)

share|improve this question
    
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format –  Christian Hupfer Mar 6 at 11:47
    
This should be possible, but it is in my point of view tedious to read an 'unordered' list of subsection entries and omitting the chapter start pages as well. –  Christian Hupfer Mar 6 at 11:49
    
Please provide information on the document class you use and if you're using any packages that are designed to help format the Table of Contents. –  Mico Mar 6 at 12:05
    
Have you had a look at tocstyle from the KOMAscript bundle? –  Crissov Mar 6 at 12:29
    
I understand some of you will think of this format uggly, but fortunatly the table of contents as this is reduced to 4 pages, i need this format, and fortunatly too it is readable and you have a lot of information in a little area, i like this format. Finally, i can't search by myself too much, i already took too much time formating the equation, numbering them correctly, section and chapters formating... so that if someone has a solution for this i will be glad to take it even not understanding it :-( –  roberto35 Mar 6 at 12:39

2 Answers 2

You can achieve your desired format using the titletoc format.

screenshot

I have used the command titlecontents command

\titlecontents{<section>}
[]             % left margin
{}             % above code
{}             % numbered format
{}             % unnumbered format
{}             % filler-page-format, e.g dots

to customize the chapter, and its sibling command titlecontents* (which removes line breaks between entries) to customize the subsection format.

This is compatible with the hyperref package, should you wish to load it.

Here's a complete MWE for you to play with.

% arara: pdflatex
% arara: pdflatex
\documentclass{book}
\usepackage{lipsum}
\usepackage{titlesec}
\usepackage{titletoc}

% indented subsection (in toc)
\titlecontents{chapter}
[0.0cm]             % left margin
{\vspace{1cm}}                  % above code
{%                  % numbered format
{{\scshape Chapter} \thecontentslabel---}%
}%
{}         % unnumbered format
{}         % filler-page-format, e.g dots

% indented subsection (in toc)
\titlecontents*{subsection}
[1.0cm]             % left margin
{}                  % above code
{%                  % numbered format
{\thecontentslabel. }%
}%
{}         % unnumbered format
{ (\thecontentspage)}         % filler-page-format
[.~]


\begin{document}
\tableofcontents

\chapter{mychapter} 
\section{mysection}
\subsection{mysubsection}
\section{mysection}
\subsection{mysubsection}
\subsection{mysubsection}
\subsection{mysubsection}
\subsection{mysubsection}
\subsection{mysubsection}
\chapter{mychapter} 
\section{mysection}
\subsection{mysubsection}
\section{mysection}
\subsection{mysubsection}
\subsection{mysubsection}
\subsection{mysubsection}
\subsection{mysubsection}
\subsection{mysubsection}
\chapter{mychapter} 
\end{document}
share|improve this answer
    
Probably \@chapapp makes more sense than Chapter since the title is in french ;-) –  karlkoeller Mar 6 at 16:29
    
@karlkoeller wouldn't babel take care of that? I ask as an honest question (I don't use it much) :) –  cmhughes Mar 6 at 16:33
    
No. Anyway \@chapapp doesn't not distinguish between Chapter and Appendix inside the ToC. See the comments in jfbu's answer. –  karlkoeller Mar 6 at 17:33

You can achieve this design with the etoc package.

The update adds code to handle the Chapter vz. Annex thing, in order for the correct (set up in French via Babel) heading in the TOC, depending on the case. In the book class, the toc file does not contain the information that we have an annex, except via the change in the numbering which goes Alphabetical. It is easier to add something in the toc to inform etoc of this, rather than testing in the chapter style if we have a Roman or an Alpha numbering.

etoc

\documentclass{book}
\usepackage[frenchb]{babel}
\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}
\usepackage{etoc}

% Something very close to the desired design is obtained using:
% \etoctoclines
% \etocsetlevel{subsection}{3}
% \etocsetlevel{subsubsection}{6}
% \etocsettocdepth {3}
% 
% But the way these etoc toc line styles are defined may look a bit
% frightening, thus we do not try to customize and define from scratch,
% starting from example from the sample code in section 30.5 of the
% manual
\renewcommand{\thechapter}{\Roman{chapter}}

\renewcommand*\etoctoclineleaders
{\hbox{\bfseries\normalsize\hbox to .75ex {\hss.\hss}}}

\newcommand*{\DotsAndPage}
{\nobreak\leaders\etoctoclineleaders\hfill\nobreak
 \makebox[\rightskip][r]{\bfseries\normalsize\etocpage}\par}

\etocsetstyle {chapter}
{\parindent 0pt\leftskip 0pt\relax \rightskip .75cm 
 \nobreak
 \etocskipfirstprefix}
{\pagebreak[3]\bigskip}
{\bfseries\large Chapter \etocnumber{} -- \etocname\par}
{}

\etocsetstyle {section}
{\parfillskip-\rightskip
 \nobreak\medskip
 \etocskipfirstprefix}
{\pagebreak[1]\smallskip\parfillskip-\rightskip}
{\bfseries\normalsize\etocnumber{} \etocname\DotsAndPage }
{\parfillskip 0pt plus 1fil\relax}

\etocsetstyle {subsection}
{\parfillskip 0pt plus 1fil\relax
 \nobreak\smallskip}
{}
{\mdseries\normalsize\etocnumber~\etocname{} (\etocpage). }
{\par\medskip}



\newcount\cnta
\begin{document}

\tableofcontents

\chapter{My Chapter 1}

\section{My Section 1}
\subsection{My sub section 1}

\section{My Section 2}

\cnta 0
\loop
  \advance\cnta 1
\subsection{My sub section \the\cnta}
  \ifnum\cnta<4
\repeat


\chapter{My Chapter 2}
\section{My Section 1}
\subsection{My sub section 1}
\section{My Section 2}

\cnta 0
\loop
  \advance\cnta 1
\subsection{My sub section \the\cnta}
  \ifnum\cnta<14
\repeat

\end{document}

Extended code to handle Annexes (the \appendix command) and unnumbered chapters (\backmatter).

\documentclass{book}
\usepackage[frenchb]{babel}
\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}
\usepackage{etoc}

\renewcommand{\thechapter}{\Roman{chapter}}
% We start from the sample code in section 30.5 of the etoc
% manual ("using depth tags")

\renewcommand*\etoctoclineleaders
{\hbox{\bfseries\normalsize\hbox to .75ex {\hss.\hss}}}

\newcommand*{\DotsAndPage}
{\nobreak\leaders\etoctoclineleaders\hfill\nobreak
 \makebox[\rightskip][r]{\bfseries\normalsize\etocpage}\par}

\etocsetstyle {chapter}
{\parindent 0pt\leftskip 0pt\relax \rightskip .75cm 
 \nobreak
 \etocskipfirstprefix}
{\pagebreak[3]\bigskip}
{\bfseries\large 
 \etocifnumbered{\ChapterOrAnnex{} \etocnumber{} -- }{}\etocname\par}
{}


% THIS IS TO GET CHAPTER OR ANNEX CORRECTLY IN THE TOC.

\newcommand*\ChapterOrAnnex{\chaptername}
\let\oldappendix\appendix
\renewcommand\appendix{\oldappendix
   \addtocontents{toc}{\def\protect\ChapterOrAnnex{\protect\appendixname}}}


\etocsetstyle {section}
{\parfillskip-\rightskip
 \nobreak\medskip
 \etocskipfirstprefix}
{\pagebreak[1]\smallskip\parfillskip-\rightskip}
{\bfseries\normalsize\etocnumber{} \etocname\DotsAndPage }
{\parfillskip 0pt plus 1fil\relax}

\etocsetstyle {subsection}
{\parfillskip 0pt plus 1fil\relax
 \nobreak\smallskip}
{}
{\mdseries\normalsize\etocnumber~\etocname{} (\etocpage). }
{\par\medskip}

\newcount\cnta
\begin{document}
\tableofcontents

\chapter{My Chapter 1}

\section{My Section 1}
\subsection{My sub section 1}

\section{My Section 2}

\cnta 0
\loop
  \advance\cnta 1
\subsection{My sub section \the\cnta}
  \ifnum\cnta<4
\repeat

\chapter{My Chapter 2}
\section{My Section 1}
\subsection{My sub section 1}
\section{My Section 2}

\cnta 0
\loop
  \advance\cnta 1
\subsection{My sub section \the\cnta}
  \ifnum\cnta<14
\repeat

\appendix
\chapter{My Annex}
\section{My Section 1}
\subsection{My sub section 1}
\section{My Section 2}

\cnta 0
\loop
  \advance\cnta 1
\subsection{My sub section \the\cnta}
  \ifnum\cnta<6
\repeat

\backmatter

\chapter{My back matter}
\section{My Section 1}
\subsection{My sub section 1}

\end{document}

extended toc

share|improve this answer
    
naturally Chapter should be Chapitre if the Table des matières heading is used.. just change the appropriate location in the chapter etoc style. –  jfbu Mar 6 at 15:32
    
Or, even better, \@chapapp ;-) –  karlkoeller Mar 6 at 16:30
    
@karlkoeller good advice, but unfortunately this will not work inside the TOC to distinguish a Chapter (Chapitre, \chaptername) from an Annex (Annexe, \appendixname). But one can test if the "chapter" is numbered, if not then use \appendixname. I will update the code thanks. –  jfbu Mar 6 at 16:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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