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.

1 Answer 1

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.

3
  • 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, 2022 at 18:48
  • @Peluche I initially tried to change just the ToC but failed. Perhaps someone else could help. Jul 20, 2022 at 16:55
  • @Peluche Surely your text editor can change all the \subsection to \mysubsec. Jul 21, 2022 at 19:31

You must log in to answer this question.

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