2

I'm using etoc to create local Table Of Contents of each chapter, but it doesn't indent it correctly. In the general TOC, it works all right, but in the local TOC, sections, subsections and paragraphs are correctly indented, while subsubsections go all the way to the left. Here is a minimal working example.

\documentclass{book}

\usepackage{tocloft}
\usepackage{etoc} 

\begin{document}

\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{3}   
\tableofcontents

\etocsetnexttocdepth{5}
\etocsettocstyle{\subsubsection*{Contents}}{}
\cftsubsubsecindent 0pt

\chapter{Title of Chapter 1} 
Some text
\localtableofcontents

\section{Section 1.1} 
Some text

\subsection{Subsection 1.1}
Some text

\subsubsection{Subsection 1.1.1}
Some text

\paragraph{Paragraph 1.1.1.1}
Some text

\end{document}

enter image description here

Any ideas?

Thank you in advance.

  • 1
    Remove \cftsubsubsecindent 0pt – egreg Sep 19 at 8:24
  • @egreg: Thanks, that worked. I took it from somewhere and did not notice that. – arauko Sep 19 at 8:35
1

The line with

\cftsubsubsecindent 0pt

is the culprit: remove it.

As a general rule, avoid borrowing preambles from your mates or whatever you find on the Net. Take them, maybe, as schemes, but build your own preamble, loading only the packages that are necessary for your project.

It may happen to copy macro code that you don't fully understand, but that comes from trustworthy sources. However, check carefully the setting section of the preamble: if you don't understand what some piece of code is doing there, comment it out and try compiling without it.

In this case you copied a statement that should have been

\setlength{\cftsubsubsecindent}{0pt}

and in this form you'd probably realize what it does: it's from tocloft because of cft, it is about an indentation because of indent and refers to subsubsections. Now it's your subsubsections that go astray, so…

The person who wrote the code you copied probably likes to obfuscate their code, by saving a few keystrokes at the expense of clarity.

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.