1

I am struggling to do some changes in the ToC. Below a simple sample.

\documentclass{book}

\begin{document}

\tableofcontents

\chapter{Part I}
\section{Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test }

\addcontentsline{toc}{subsection}{Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test }

\end{document}

The ToC created with this code is shown in the figure below enter image description here

My question is: Is there a easy way to avoid the indentation in ToC when \addcontentsline is used?

Bonus question: Is there a way to hide the page number in ToC for chapters containing \section and \subsection?

Thanks in advance!

3
  • @Bernard should the last one be titletoc?
    – daleif
    Oct 15, 2019 at 9:12
  • @dalif;: yes, sorry for the typo. I'll rewrite my comment since I can't edit it now. Thanks!
    – Bernard
    Oct 15, 2019 at 10:00
  • 1
    You can take a look at the dedicated packages: etoc, tocloft and titletoc (which comes with titlesec).
    – Bernard
    Oct 15, 2019 at 10:01

1 Answer 1

2

Alter the \l@subsection value from the book.cls file can meet the expectaion, and the MWE is:

\begin{document}
\makeatletter
\renewcommand\l@subsection{\@dottedtocline{2}{3.8em}{0em}}
\makeatother

But, it is better to achieve the requirement by using either tocloft or titletoc as suggested by Bernard...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .