2

Heydo!

I need to include the first pages to TOC and NOT include page numbers. How I can I achieve this? \listoffigures and \listoftables makes a dotted line and a page number to TOC which I want to get rid of. I've searched for a number of questions but I always find answers to remove page number IN toc, which I have done already.

My table of contents should look like this:

ABSTRACT
LIST OF FIGURES
LIST OF TABLES
CONTENTS
CHAPTER 1...................................6
CHAPTER 2...................................7

Minimal working example:

% docmentclass
\documentclass[12pt]{article}

% table of contents package 
\usepackage{tocloft}        

% package to enable commands after pages
\usepackage{afterpage}      

% dots to TOC
\AtBeginDocument{                                               
    \renewcommand{\cftsecleader}{\cftdotfill{\cftsecdotsep}}    
    \renewcommand\cftsecdotsep{\cftdot}                         
    \renewcommand\cftsubsecdotsep{\cftdot}                      
    \renewcommand{\cftfigleader}{\cftdotfill{\cftsecdotsep}}
    \renewcommand{\cfttableader}{\cftdotfill{\cftsecdotsep}}
    }

%remove incremental number from TOC
\let\oldsection\section 
\newcommand{
    \abstractsection}[1]{ 
      \newpage
      \oldsection*{#1}
      \addcontentsline{toc}{section}{#1}
    }

%for captions to show up in lof and lot
\usepackage{caption}

\begin{document}

%frontcover
\begin{center}
    \vspace*{5cm}
    \normalsize{Tuomas-Matti Soikkeli} \\
    \large{Front Cover}
    \vfill{}
\end{center} 

%abstract
\abstractsection{ABSTRACT}
Some abstract content
\newpage

%list of figures and list of tables
\listoffigures
\addcontentsline{toc}{section}{LIST OF FIGURES}
\listoftables
\addcontentsline{toc}{section}{LIST OF TABLES}
\newpage

%ToC
\tableofcontents 
\addcontentsline{toc}{section}{CONTENTS}
\newpage

%contents
\section{FIRST CHAPTER}
\begin{figure}[H]
  figure
  \caption[EXAMPLE FIGURE]{example figure}
\end{figure}

\section{SECOND CHAPTER}
\begin{table}[h]
table
\caption[EXAMPLE TABLE]{example table}
\end{table}

\end{document}

Ends up being:

TOC.png

2

You should use some of the functionality provided by tocloft. Instead of using \addcontentsline{<file>}{<type>}{<title>}, use \cftaddtitleline{<file>}{<type>}{<title>}{<page>}. Using the latter allows you to use an empty <page> argument:

enter image description here

\documentclass{article}

% Table of Contents package 
\usepackage{tocloft}        

% dots to TOC
\AtBeginDocument{                                               
  \renewcommand{\cftsecleader}{\cftdotfill{\cftsecdotsep}}    
  \renewcommand\cftsecdotsep{\cftdot}                         
  \renewcommand\cftsubsecdotsep{\cftdot}                      
  \renewcommand{\cftfigleader}{\cftdotfill{\cftsecdotsep}}
  \renewcommand{\cfttableader}{\cftdotfill{\cftsecdotsep}}
}

%remove incremental number from TOC
\newcommand{\abstractsection}[1]{%
  \clearpage
  \section*{#1}
  \cftaddtitleline{toc}{section}{#1}{}%
}

\begin{document}

\addtocontents{toc}{\protect\renewcommand{\protect\cftsecleader}{\hfill}}

%abstract
\abstractsection{ABSTRACT}

Some abstract content

\clearpage

% List of Figures and List of Tables
\listoffigures
\cftaddtitleline{toc}{section}{LIST OF FIGURES}{}%
\listoftables
\cftaddtitleline{toc}{section}{LIST OF TABLES}{}%

\clearpage

% Table of Contents
\tableofcontents 
\cftaddtitleline{toc}{section}{CONTENTS}{}%

\clearpage

\addtocontents{toc}{\protect\renewcommand{\protect\cftsecleader}{\protect\cftdotfill{\protect\cftsecdotsep}}}

%contents
\section{FIRST CHAPTER}
\begin{figure}[ht]
  figure
  \caption[EXAMPLE FIGURE]{example figure}
\end{figure}

\section{SECOND CHAPTER}
\begin{table}[ht]
  table
  \caption[EXAMPLE TABLE]{example table}
\end{table}

\end{document}

Additionally, you have to insert (very strategically) entries into the ToC file to remove the leaders. I've done so and commented those locations above. The .toc file should now resemble:

\renewcommand {\cftsecleader }{\hfill }
\contentsline {section}{ABSTRACT}{}
\contentsline {section}{LIST OF FIGURES}{}
\contentsline {section}{LIST OF TABLES}{}
\contentsline {section}{CONTENTS}{}
\renewcommand {\cftsecleader }{\cftdotfill {\cftsecdotsep }}
\contentsline {section}{\numberline {1}FIRST CHAPTER}{5}
\contentsline {section}{\numberline {2}SECOND CHAPTER}{5}

This way of adjusting the ToC-related content is necessary, since the ToC is processed as a whole before the rest of the document is set. You have to insert the adjustments within your document that correspond to the sequence within the ToC.

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.