First an MWE and its output:
\documentclass[a4paper, 10pt]{book}
\usepackage{hyperref}
\usepackage{imakeidx}
\makeindex
\newcommand{\AddIndexLetterToTOC}[1]{\textbf{#1}\phantomsection\addcontentsline{toc}{section}{#1}}
\usepackage{filecontents}
\begin{filecontents}[overwrite]{\jobname.mst}
headings_flag 1 %
heading_prefix "\AddIndexLetterToTOC{"
heading_suffix "}\nopagebreak\n"
delim_0 "\dotfill"
delim_1 "\dotfill"
delim_2 "\dotfill"
\end{filecontents}
\begin{document}
\tableofcontents
\chapter{Test chapter}
\index{And}
\index{Book}
\index{Summer}
\index{Latex}
\pagebreak
\addcontentsline{toc}{chapter}{Index}
\printindex
\end{document}
As you see, the dot spaces in Contents and Index are different, so
(question 1) is there any way to make the dot space in Index be the same as that in Contents, and to keep the dot space in Contents be unchanged?
I know an answer with the help of the tocloft package which I don't want to use since it will change some other setting in my .tex files. Or
(question 2) is there any way to make the dot space in Contents be the same as that in Index, and to keep the dot space in Index be unchanged?
By the way, the definition of \@dottedtocline for Contents is as follows:
\ifnum #1>\c@tocdepth \else
\vskip \z@ \@plus .2\p@
{\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
and the definition for \dotfill for Index is also as follows:
\def\dotfill{\leaders\hbox to.6em{\hss .\hss}\hskip\z@ plus 1fill\kern\z@}%
But I don't know how to get the desired result after reading them.






\leadersin the TOC macro in details? – M. Logic May 23 '22 at 05:55\def\@dottedtocline#1#2#3#4#5{...}from thelatex.ltxfile, modify it and save it to your macros. Of course, your macros are surrounded by\makeatletterand\makeatotherin your macro file. – wipet May 23 '22 at 06:13latex.ltxchanged? And where to find the file? – M. Logic May 23 '22 at 07:42latex.ltxintexmf-dist/tex/latex/base/. I supposed that you know about this file because you cited from it in your OP: "By the way, the definition of\@dottedtoclinefor Contents is as follows". – wipet May 23 '22 at 07:46\texlive/2022/texmf-dist/tex/latex/base/in the MacTeX. – M. Logic May 23 '22 at 08:07