# Remove all page numbers from the table of content

I want to send the table of content of a document containing only section and subsection titles. Sections of the document are empty, therefore, page numbers do not make sense at this stage. I get a big column of useless page numbers on the right.

Title ............. 3
Title ............. 3
Title ............. 3


I do not want to remove a few page numbers from the TOC numbering as asked here, here or here. But I want to remove all page numbers from the TOC. The table of content would look like this

Title .............
Title .............
Title .............


Or better, without the dots:

Title
Title
Title


Use tocloft. From its manual:

A sample:

\documentclass{article}
\usepackage{tocloft}
\usepackage{blindtext}
\cftpagenumbersoff{section}
\cftpagenumbersoff{subsection}
\cftpagenumbersoff{subsubsection}
\begin{document}
\tableofcontents
\Blinddocument
\end{document}


Now wondering how to publish the TOC only, but that's probably for another question.

Let us say the name of your .tex file is myfile.tex with the following content:

\documentclass{article}
\usepackage{blindtext}   % for demo only
\begin{document}
\tableofcontents
\Blinddocument
\end{document}


Compile this 2-3 times. This will generate an auxiliary file named myfile.toc.

Now prepare anothe .tex file name mytoc.toc, say, with the following contents:

\documentclass{article}
\begin{document}
\input{myfile.toc}
\end{document}


Compile this to get only the toc of myfile.tex.

• Since I am a nice guy (sometimes ;-)) (+1) – user31729 Nov 2 '15 at 11:10
• @ChristianHupfer: Today! They won't count anyway :) – user11232 Nov 2 '15 at 11:11
• Thanks @HarishKumar, I added \usepackage{tocloft}, \cftpagenumbersoff{part}, \cftpagenumbersoff{section}, \cftpagenumbersoff{subsection}, to the latex preamble. And I get the desired result. Now wondering how to publish the TOC only, but that's probably for another question. – Paul Rougieux Nov 2 '15 at 12:41
• @Paul4forest Please see the update. – user11232 Nov 3 '15 at 5:22

The entries for the ToC (and LoF, LoT etc.) are done with \addcontentsline, more precisely:

\def\addcontentsline#1#2#3{%


If \thepage is removed from the \contentsline call, all page numbers will be dropped.

If the page numbers for particular structuring levels should be removed use tocloft and its \cftpagenumbersoff{section} command etc. (as Harish Kumar showed in his answer)

\documentclass{book}

\usepackage{xpatch}

\usepackage{blindtext}
\begin{document}
\tableofcontents
\blinddocument

\end{document}


• @HarishKumar: I am at home ;-) School holidays – user31729 Nov 2 '15 at 11:11
• @HarishKumar: No children (yet)... and I will grab all TikZ and tcolorbox questions then :-P – user31729 Nov 2 '15 at 11:13
• And how to avoid the dotted lines as well? I'm asking, because it looks strange: lines without an end. – Keks Dose Nov 2 '15 at 12:55
• @KeksDose: The O.P. wanted to have them, see his post. – user31729 Nov 2 '15 at 13:25
• Yes, I know, but I am courious myself ! – Keks Dose Nov 2 '15 at 14:36