[Tex/LaTex] Table of contents not dotfilling

table of contents

Is this wrong?

Table of Contents

It seems the ToC does dotfilling only for sections and not subsections. Why is this happening and how can I fix it?

I'm using \tableofcontents and nothing else to generate this ToC, the document class is article.

Edit: Yes; I want to fill the space in the sections with dots, from the end of the section title to the beginning of the number, just like how it fills with dots the subsection 5.1

MWE below:

   \documentclass[a4paper,spanish]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage[spanish]{babel}
\usepackage{graphicx} 
\usepackage{wrapfig}
\usepackage{setspace}
\usepackage[right]{eurosym}
\usepackage{rotating}
\usepackage{ccicons}
\usepackage{multirow}
\usepackage{tabu}
\usepackage{amsmath,amssymb,amsthm,amscd}
\usepackage{amsmath}
\graphicspath{{./Imagenes/}} %Lugar en el que se guardarán las imágenes
\itemsep 1ex
\newcommand{\RNum}[1]{\uppercase\expandafter{\romannumeral #1\relax}}
\begin{document}

\tableofcontents % Índice

\newpage % Salto de página

\section{Los tres tipos generales de conocimiento} % Sección superior
bar
\section{Superioridad del saber-que}
foo
\section{Lo inefable}
barfoo
\section{Las condiciones de la verdad}
foobar
\section{Las fuentes del conocimiento}
bar
\subsection{La experiencia sensorial}
foo
\end{document}

Best Answer

If you don't want to look for the right lengths to give as parameters to tocloft or titletoc commands, you can also patch the \l@section command to use the same leaders as the other commands instead of blank space:

\documentclass[a4paper]{article}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\l@section}
  {\hfil}
  {\leaders\hbox{\normalfont$\m@th\mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$}\hfill}
  {}{}
\makeatother

\begin{document}

\tableofcontents % Índice

...
\end{document}

enter image description here

Related Question