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.

This question is almost a repeat of previous one : How do I get multiple ToC entries in the same line?. However, I need an answer using tocloft, not titletoc, since tocloft customization capabilities are better in my views that titletoc ones. Do you thing it is feasible with tocloft?

EDIT: Here is what I would like to get, the subsubsection in the book class are on the same line, with no numbering but with page numbers:

enter image description here

share|improve this question
    
Related: tex.stackexchange.com/questions/78980/… –  lockstep Nov 15 '12 at 11:54
    
Yes, it is doable. What entries should be displayed in a paragraph style? –  Gonzalo Medina Nov 15 '12 at 14:30
    
I need the subsubsection to be displayed in a paragraph style. I am currently playing with the etoolbox like in the question mentioned by lockstep, but I did not reach my target yet. –  Martigan Nov 15 '12 at 18:22
    
And how should the entries be formatted? As in the example you linked in your question (i.e., no subsubsection number, only the title and the page number)? –  Gonzalo Medina Nov 16 '12 at 1:43
    
I added an edit to show the effect I would like to get, and the format I would like. @GonzaloMedina –  Martigan Nov 16 '12 at 14:03
show 1 more comment

1 Answer 1

up vote 4 down vote accepted

Here's one possible solution, using a variation of the technique used in this answer to How to emulate titletoc with tocloft:

\documentclass{book}
\usepackage{etoolbox}

\newlength\rightmargintoc
\setlength\rightmargintoc{\linewidth}
\addtolength\rightmargintoc{-3em}

\makeatletter
\def\subsubsectocline#1#2#3#4#5{%
\parshape 2  0em \rightmargintoc \dimexpr\parindent\relax \rightmargintoc
\@tempdima#3
\ifdim\lastskip=1sp\relax\ \else\par\fi{\small\itshape#4,~p.#5.}\hskip1sp%
}
\renewcommand*\l@subsubsection{\subsubsectocline{2}{0em}{3em}}
\makeatother

\pretocmd{\part}{\addtocontents{toc}{\par}}{}{}
\pretocmd{\chapter}{\addtocontents{toc}{\par}}{}{}
\pretocmd{\section}{\addtocontents{toc}{\par}}{}{}
\pretocmd{\subsection}{\addtocontents{toc}{\par}}{}{}

\AtEndDocument{\addtocontents{toc}{\par}}

\begin{document}
\addtocontents{toc}{\setcounter{secnumdepth}{2}}
\tableofcontents

\part{Test Part One}
\chapter{Test Chapter}
\section{Test Section One}
\subsection{Test Subsection One One}
\subsubsection{First Test Subsubsection}
\subsubsection{Second Test Subsubsection}
\subsubsection{Third Test Subsubsection}
\newpage
\subsubsection{Fourth Test Subsubsection}
\subsection{Test Subsection One Two}
\subsubsection{First Test Subsubsection}
\subsubsection{Second Test Subsubsection}
\subsubsection{Third Test Subsubsection}
\part{Test Part One}
\chapter{Test Chapter}
\section{Test Section One}

\end{document}

The resulting ToC:

enter image description here

share|improve this answer
    
Thank you very much, it is working great. I don't know why I did not succeed in adaptating your previous answer... There remains an issue, in the book class, with the parts in the toc. the part toc entry starts right after the last subsubsection item. Do you know why? I can add a phantom section and try to reduce vertical space, but it is quite ugly. @GonzaloMedina –  Martigan Nov 17 '12 at 13:37
    
@Martigan there was a problem with my code that now I've fixed. Please try the improved version (delete the auxiliary files first) of my updated answer. –  Gonzalo Medina Nov 17 '12 at 13:53
    
Thanks a lot. It is now working perfectly. @GonzaloMedina –  Martigan Nov 17 '12 at 14:19
add comment

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.