Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
Do you really mean that you have dots for section? \part and section are the levels without dots in the table of contents. –  Marco Daniel Mar 9 '13 at 20:04
add comment

2 Answers

up vote 4 down vote accepted

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

share|improve this answer
    
Thank you for your detailed explanation and illustrated example on this! Very much appreciating the quick response aswell! Cheers :) This is exactly what I was looking for!! –  Pyrobisqit Mar 10 '13 at 0:16
add comment

In article.cls the default behaviour for section entries in the ToC is not to use the dotted leaders; if you want to have these, you can use the tocloft package and redefine \cftsecleader to have the dots:

\documentclass{article}
\usepackage{tocloft}

\renewcommand\cftsecleader{\cftdotfill{\cftdotsep}}

\begin{document}

\tableofcontents
\section{Test Section}
\subsection{Test Subsection}

\end{document}

enter image description here

Another option would be to use the titletoc package and its \dottedcontents command:

\documentclass{article}
\usepackage{titletoc}

\dottedcontents{section}[1.5em]{\bfseries}{1.3em}{.6em}

\begin{document}

\tableofcontents
\section{Test Section}
\subsection{Test Subsection}

\end{document}

enter image description here

Yet another option, not requiring additional packages, would be to redefine the internal command \l@section (in charge of typesetting section entries in the ToC) to use \@dottedtocline:

\documentclass{article}

\makeatletter
\renewcommand*\l@section{\@dottedtocline{1}{0em}{1.5em}}
\makeatother

\begin{document}

\tableofcontents
\section{Test Section}
\subsection{Test Subsection}

\end{document}

enter image description here

share|improve this answer
1  
And with tocstyle it is also possible. –  Speravir Mar 9 '13 at 23:07
    
Thanks for your accurate and detailed listing of the several methods available, I'm just learning LaTeX and I'm already loving it. Your answer is highly appreciated :) –  Pyrobisqit Mar 10 '13 at 0:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.