TransWikia.com

How to remove reference page numbers in table of contents

TeX - LaTeX Asked on February 11, 2021

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}{normalfontLargebfseries}{makebox[30pt][l]{thesection}}{0pt}{} 
titleformat{subsection}{normalfontlargebfseries}{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}

One Answer

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}

Answered by Mico on February 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP