0

I'm going to apply this: How to hide/show section levels in the table of contents? but I also want to not show the numbering in the subsection label. For example, in the next picture I want the subsection label appear BUT without the numbering.

enter image description here

Is that possible? The text is in spanish but the idea is the same. I'm using a book as document class. What I want to get is (using enumerate and itemize environments):

enter image description here

That's what I want in the ToC.

Peluche
  • 613

1 Answers1

1

Try this:

% tocsubsecprob.tex  SE 651288
\documentclass{report}
\usepackage{tocloft}
\setcounter{tocdepth}{1}

% stop \chapter starting a new page \usepackage{etoolbox} \makeatletter \patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{} \makeatother

% print \subsection as requested in the body and the ToC \newcommand{\mysubsec}[1]{\subsection{#1}% \addcontentsline{toc}{section}{\hspace{2em}$\bullet$ #1}} \begin{document}

\tableofcontents

\chapter{A chapter} \section{A section} \subsection{First subsection} \addcontentsline{toc}{section}{\hspace{2em}$\bullet$ First subsection} \subsection{Another subsection} \addcontentsline{toc}{section}{\hspace{2em}$\bullet$ Another subsection} \mysubsec{Third subsection} \section{Another section} \end{document}

enter image description here

Please acknowledge.

Peter Wilson
  • 28,066
  • It works fantastic and I love it but I'd have to change all the sections commands. Do you know any way to do that but changing directly the ToC and not by creating a new command? My english's still a work in progress, sorry if I'm writing incorrectly some things. – Peluche Jul 19 '22 at 18:48
  • @Peluche I initially tried to change just the ToC but failed. Perhaps someone else could help. – Peter Wilson Jul 20 '22 at 16:55
  • @Peluche Surely your text editor can change all the \subsection to \mysubsec. – Peter Wilson Jul 21 '22 at 19:31