1

I haven't found a solution for this online and not sure what it's called, but I want to remove the numbers on the right of my table of contents for my subsectionsenter image description here

here is the code I have so far for my ToC

%align numbers and TOC
\titleformat{\section}{\normalfont\Large\bfseries}{\makebox[30pt][l]{\thesection}}{0pt}{} 
\titleformat{\subsection}{\normalfont\large\bfseries}{\makebox[30pt][l]{\thesubsection}}{0pt}{}

%TOC spacing
\usepackage{tocloft}
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
\renewcommand{\cftsubsecleader}{\hfill}
\setcounter{tocdepth}{2}
\renewcommand{\cftsecafterpnum}{\vspace{0pt}}
\setlength{\cftsecnumwidth}{30pt}
\setlength{\cftsubsecnumwidth}{30pt}
\setlength{\cftsubsecindent}{60pt}
1
  • Welcome to TeX.SE.
    – Mico
    Commented Sep 14, 2020 at 17:06

1 Answer 1

1

Adding

\makeatletter
\renewcommand{\cftsubsecpagefont}{\@gobble}
\makeatother

to the preamble will let you achieve your formatting objective.


A full MWE:

enter image description here

\documentclass{article}
\usepackage{tocloft}
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
\renewcommand{\cftsubsecleader}{\hfill}
\makeatletter
\renewcommand{\cftsubsecpagefont}{\@gobble}
\makeatother
\renewcommand{\cftsecafterpnum}{\vspace{0pt}}
\setlength{\cftsecnumwidth}{30pt}
\setlength{\cftsubsecnumwidth}{30pt}
\setlength{\cftsubsecindent}{60pt}

\begin{document}
\tableofcontents

\section{Introduction}
\subsection{Goals of the Experiment}
\subsection{Background Information}
\section{Hypothesis}
\end{document}

You must log in to answer this question.

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