2

I'm trying to add unnumbered subsubsections to my ToC while keeping it properly indented and without removing the title numbers within the text. Here is the example and code of what I have but don't want:

basic code

\documentclass[11pt]{article}
\usepackage{tocloft}

\begin{document}

\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
\cftpagenumbersoff{part} % suppress page number in toc for parts
\tableofcontents
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
\renewcommand{\thesubsection}
    {\arabic{subsection}}
\renewcommand{\thesubsubsection}
    {\Alph{subsubsection}}
\newpage

\part*{Part}
\addcontentsline{toc}{part}{Part}
\section{Section1}
\section{Section2}
\subsection{Subsection1}
\subsubsection{SubsubsectionA}
\subsubsection{SubsubsectionB}
\section{Section3}

\end{document}

When I remove the subsubsection numbering with \setcounter{secnumdepth}{2}, it also removes the indent, flushing it even with the subsection. Below is that result.

depth at 2

I'd also like to avoid the above solution as it removes the title numbers within the text, which I want to keep. Below is the ideal solution I'd like to achieve: A properly indented ToC that includes the subsubsection without section number BUT still includes the section number within the text.

IDEAL SOLUTION ideal solution 1

If that's impossible or too difficult, then simply changing the indent space between the subsubsection number and the title would be fine, as in:

LESS IDEAL SOLUTION 1 less ideal solution 1

or

LESS IDEAL SOLUTION 2 less ideal solution 2

0

2 Answers 2

1

Here is a suggestion using package tocbasic instead tocloft (do not use both!):

\documentclass[11pt]{article}

\usepackage{tocbasic}
\DeclareTOCStyleEntry[
  pagenumberformat=\gobble,
  numwidth=0pt
]{tocline}{part}
\DeclareTOCStyleEntry[
  entrynumberformat=\gobble,
  numwidth=2em
]{tocline}{subsubsection}
\newcommand\gobble[1]{}

\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}

\renewcommand{\thesubsection}{\arabic{subsection}}
\renewcommand{\thesubsubsection}{\Alph{subsubsection}}

\begin{document}
\tableofcontents
\clearpage
\part*{Part}\addcontentsline{toc}{part}{Part}
\section{Section1}
\section{Section2}
\subsection{Subsection1}
\subsubsection{SubsubsectionA}
\subsubsection{SubsubsectionB}
\section{Section3}
\end{document}

enter image description here


Regarding a comment below:

If you want to decrease the space between subsection number and its title in TOC, you can use

\DeclareTOCStyleEntry[
  numwidth=1.5em
]{tocline}{subsection}

Then I would change numwidth for subsection too.

enter image description here

Code:

\documentclass[11pt]{article}

\usepackage{tocbasic}
\DeclareTOCStyleEntry[
  pagenumberformat=\gobble,
  numwidth=0pt
]{tocline}{part}
\DeclareTOCStyleEntry[
  numwidth=1.5em
]{tocline}{subsection}
\DeclareTOCStyleEntry[
  entrynumberformat=\gobble,
  numwidth=1.5em
]{tocline}{subsubsection}
\newcommand\gobble[1]{}

\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}

\renewcommand{\thesubsection}{\arabic{subsection}}
\renewcommand{\thesubsubsection}{\Alph{subsubsection}}

\begin{document}
\tableofcontents
\clearpage
\part*{Part}\addcontentsline{toc}{part}{Part}
\section{Section1}
\section{Section2}
\subsection{Subsection1}
\subsubsection{SubsubsectionA}
\subsubsection{SubsubsectionB}
\section{Section3}
\end{document}
2
  • This works great thank you so much! While we're here, would you know how to decrease the huge space between 1 and Subsection1 in the ToC?
    – vm-ta
    Apr 25, 2018 at 9:10
  • @VincentMQ You can change numwidth for subsection, too. See my updated answer.
    – esdd
    Apr 25, 2018 at 9:40
1

The tocloft manual is rather well done and is also a very good reference on LaTeX2e's parameters for table of contents. Here we use the parameters provided by tocloft itself. I recommend you read the manual.

\documentclass[11pt]{article}
\usepackage{tocloft}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{2}
\cftpagenumbersoff{part} % suppress page number in toc for parts

\setlength{\cftsubsubsecindent}
    {\dimexpr\cftsubsubsecindent+\cftsubsubsecnumwidth\relax}

\renewcommand{\thesubsection}{\arabic{subsection}}
\renewcommand{\thesubsubsection}{\Alph{subsubsection}}

\begin{document}

\tableofcontents

\newpage

\part*{Part}
\addcontentsline{toc}{part}{Part}
\section{Section1}
\section{Section2}
\subsection{Subsection1}
\subsubsection{SubsubsectionA}
\subsubsection{SubsubsectionB}
\section{Section3}

\end{document}

enter image description here

1
  • you can naturally adjust the indent to the desired width. The point is that you can use \cftsubsubsecindent on "both sides" of \setlength. For example on right side \cft...indent + 2em inside the \dimexpr.
    – user4686
    Apr 25, 2018 at 7:27

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.