[Tex/LaTex] Remove Leading Dots in Part of Table of Contents

fontsformattingspacingtable of contents

I am currently struggling with a few table of contents issues on LaTeX. I am trying to remove the leading dots on just one part of the table of contents, creating a consistent double-spacing throughout, and consistent space between chapter number and chapter title. I will say that I am using a style file from UNT that I have slightly edited, but below I have included some of the code that produces the table of contents:

\documentclass[12pt, titlepage, openany]{amsbook}

\addcontentsline{toc}{chapter}{TABLE OF CONTENTS}%\dotfill}
\addtocontents{toc}{\protect\contentsline{chapter}{CHAPTER}{}{}}
\makeatletter
\renewcommand\tocchapter[3]{%
  \indentlabel{\@ifnotempty{#2}{\ignorespaces#2.\quad}}#3\dotfill%
}
\makeatother
\begin{doublespace}
\tableofcontents
\end{doublespace}

\usepackage{amsmath}
\begin{document}

That I know of, I am not using the tocloft package since I seem to always get errors when I try to compile and everything seems to be working fine without it despite this one issue. There are also two modifications that I have used which were found online:

1).

\makeatletter
\def\@tocline#1#2#3#4#5#6#7{\relax
\ifnum #1>\c@tocdepth % then omit
\else
\par \addpenalty\@secpenalty\addvspace{#2}%
\begingroup \hyphenpenalty\@M
\@ifempty{#4}{%
  \@tempdima\csname r@tocindent\number#1\endcsname\relax
}{%
  \@tempdima#4\relax
}%
\parindent\z@ \leftskip#3\relax \advance\leftskip\@tempdima\relax
\rightskip\@pnumwidth plus4em \parfillskip-\@pnumwidth
#5\leavevmode\hskip-\@tempdima #6\nobreak\relax
\ifnum#1<0\hfill\else\dotfill\fi\hbox to\@pnumwidth{\@tocpagenum{#7}}\par
\nobreak
\endgroup
\fi}
\makeatother

2).

\makeatletter
\def\@dottedtocline#1#2#3#4#5{%
\ifnum #1>\c@tocdepth \else
\vskip \z@ \@plus.2\p@
{\ifnum #1>\c@sectocnonumdepth \def\numberline##1{\hb@xt@\@tempdima{\hfil}}\fi%
 \leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
 \parindent #2\relax\@afterindenttrue
 \interlinepenalty\@M
 \leavevmode
 \@tempdima #3\relax
 \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
 {#4}\nobreak
 \leaders\hbox{$\m@th
    \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
    mu$}\hfill
 \nobreak
 \hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #5}%
 \par}%
\fi}
\makeatother


\addcontentsline{toc}{chapter}{TABLE OF CONTENTS}%\dotfill}
\addtocontents{toc}{\protect\contentsline{chapter}{CHAPTER}{}{}}
\makeatletter
\renewcommand\tocchapter[3]{%
\indentlabel{\@ifnotempty{#2}{\ignorespaces#2.\enskip }}#3\dotfill%
}
\makeatother
\begin{doublespace}
\tableofcontents
\end{doublespace}

\end{document}

And lastly, here is a screenshot of how it looks

Just to be clear, I need to remove the leading dots from the word CHAPTER following the words TABLE OF CONTENTS, and create a consistent spacing. Any assistance on this is greatly appreciated. A million thanks in advance.

EDIT

So I was able to fix the spacing issue a lot better compared to how it is seen in the picture. I used the \enskip command instead of the \quad that was originally there. However I am still stuck on removing the leading dots from the word CHAPTER following the words TABLE OF CONTENTS. As always, any help is always welcomed and greatly appreciated.

Best Answer

I've removed an extra \dotfill from \tocchapter since there is already a \dotfill as part of \@tocline. Secondly, I've created a macro that specifically handles your CHAPTER entry via a local redefinition within the ToC itself:

enter image description here

\documentclass{amsbook}

\usepackage{blindtext}

\makeatletter
\renewcommand\tocchapter[3]{%
  \indentlabel{\@ifnotempty{#2}{\ignorespaces#2.\quad}}#3%
}
\makeatother

\makeatletter
\def\@tocline#1#2#3#4#5#6#7{\relax
  \ifnum #1>\c@tocdepth % then omit
  \else
    \par \addpenalty\@secpenalty\addvspace{#2}%
    \begingroup \hyphenpenalty\@M
    \@ifempty{#4}{%
      \@tempdima\csname r@tocindent\number#1\endcsname\relax
    }{%
      \@tempdima#4\relax
    }%
    \parindent\z@ \leftskip#3\relax \advance\leftskip\@tempdima\relax
    \rightskip\@pnumwidth plus4em \parfillskip-\@pnumwidth
    #5\leavevmode\hskip-\@tempdima #6\nobreak\relax
    \ifnum#1<0\hfill\else\dotfill\fi\hbox to\@pnumwidth{\@tocpagenum{#7}}\par
    \nobreak
    \endgroup
  \fi}
\makeatother

% Create a way of treating CHAPTER
\makeatletter
\DeclareRobustCommand{\l@specialchapter}{%
  \let\@tocpagenum\@gobble
  \@tocline{-1}{8pt plus 1pt}{0pt}{}{}}
\makeatother

\begin{document}

\clearpage
\addcontentsline{toc}{chapter}{TABLE OF CONTENTS}%\dotfill}
\tableofcontents

% Update the chapter ToC entries to use \l@specialchapter
\makeatletter
\addtocontents{toc}{\begingroup
  \let\protect\l@chapter\l@specialchapter}
\addcontentsline{toc}{chapter}{CHAPTER}
\addtocontents{toc}{\endgroup}
\makeatother

\blinddocument

\end{document}