2

I want to get rid of the dots from the subsections. I would also like to have the same ToC vertical line spacing for the sections and subsections. Right now, the code below prints dots for sections and subsections, and the subsections are squeezed together in the ToC. Thanks!

enter image description here

\documentclass[letterpaper,twoside,notitlepage]{article}
\setcounter{tocdepth}{2}
\usepackage{titletoc}
\usepackage{tocloft}
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}

%%%%%%%%%NO SECTION NUMBERS IN TOC%%%%%%%%%%%%%%%%%%%
\makeatletter
\let\latexl@section\l@section
\def\l@section#1#2{\begingroup\let\numberline\@gobble\latexl@section{#1}{#2}\endgroup}
\let\latexl@subsection\l@subsection
\def\l@subsection#1#2{\begingroup\let\numberline\@gobble\latexl@subsection{#1}{#2}\endgroup}
\makeatother

\begin{document}
%%%%%%%%%%%% SET TOC LINE SPACING%%%%%%%%%%%%%%%%
\renewcommand{\baselinestretch}{1}\normalsize
\addtocontents{toc}{\protect\thispagestyle{empty}}
\tableofcontents
\thispagestyle{empty}
\renewcommand{\baselinestretch}{1.5}\normalsize

\newpage

\section{Section 1} 
\subsection{Subsection 1}
\subsection{Subsection 2}
\subsection{Subsection 3}
\section{Section 2} 
\section{Section 3} 
\section{Section 4}  
\end{document}

1 Answer 1

3

Adding this to your preamble should do what you want:

\setlength{\cftbeforesubsecskip}{1\baselineskip}
\renewcommand{\cftsubsecdotsep}{\cftnodots}

For further information see the tocloft manual pages 8 through 12.

Complete code:

\documentclass[letterpaper,twoside,notitlepage]{article}
\setcounter{tocdepth}{2}
\usepackage{titletoc}
\usepackage{tocloft}
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}

%%%%%%%%%NO SECTION NUMBERS IN TOC%%%%%%%%%%%%%%%%%%%
\makeatletter
\let\latexl@section\l@section
\def\l@section#1#2{\begingroup\let\numberline\@gobble\latexl@section{#1}{#2}\endgroup}
\let\latexl@subsection\l@subsection
\def\l@subsection#1#2{\begingroup\let\numberline\@gobble\latexl@subsection{#1}{#2}\endgroup}
\makeatother

\setlength{\cftbeforesubsecskip}{1\baselineskip}
\renewcommand{\cftsubsecdotsep}{\cftnodots}

\begin{document}
    %%%%%%%%%%%% SET TOC LINE SPACING%%%%%%%%%%%%%%%%
    \renewcommand{\baselinestretch}{1}\normalsize
    \addtocontents{toc}{\protect\thispagestyle{empty}}
    \tableofcontents
    \thispagestyle{empty}
    \renewcommand{\baselinestretch}{1.5}\normalsize
    
    \newpage
    
    \section{Section 1} 
    \subsection{Subsection 1}
    \subsection{Subsection 2}
    \subsection{Subsection 3}
    \section{Section 2} 
    \section{Section 3} 
    \section{Section 4}  
\end{document}

enter image description here

You must log in to answer this question.

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