23

Possible Duplicate:
Changing the TOC style of an Article document-class

When I use \tableofcontents, It uses ... as a filler between title and page number for subsections, How I can force it to fill space between title of sections and page numbers as well?

37

I had a confusion :- Whether you want dots or you don't. If you don't, this is a solution you can use tocloft with \renewcommand{\cftdot}{}.

\documentclass[11pt]{report}
\usepackage{tocloft}
% ----------------------------------------------------------------
\begin{document}

\renewcommand{\cftdot}{} %empty {} for no dots. you can have any symbol inside. For example put {\ensuremath{\ast}} and see what happens.
\tableofcontents

\chapter{one}

\section{one}

\end{document}

If you want dots even for chapters and parts this will help you.

\documentclass[11pt]{report}
\usepackage{tocloft}
\renewcommand{\cftpartleader}{\cftdotfill{\cftdotsep}} % for parts
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} % for chapters
%\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}} % for sections, if you really want! (It is default in report and book class (So you may not need it).
% ----------------------------------------------------------------
\begin{document}
\tableofcontents    
\part{Part one}
\chapter{Chapter one}    
\section{Section one}
\subsection{subsection one}    
\end{document}
| improve this answer | |
8

If you want to remove the dots you can use,

  \renewcommand\@dotsep{1000}

This sets the separation of the dots to a high figure and they vanish. (The LaTeX default figure is 4.5). Since the command includes an \@ you will have to enclose it within \makeatletter .... \makeatother.

To add dots in the section for the article class, you need to redefine the \l@section command:

\documentclass{article}
\makeatletter
\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.3em}}
\makeatother
\begin{document}
\tableofcontents
\section{test}
\end{document}
| improve this answer | |
  • 3
    I think the question was meant the other way round: How to get dots also for sections :-) – Stephan Lehmke May 1 '12 at 5:15
  • Thanks, But above comment is correct! – PHPst May 1 '12 at 5:39
  • 1
    B@Reza: But for sections dotfill will work without doing any thing. You are not getting it? – user11232 May 1 '12 at 5:43
  • @Reza The dots for sections come for free:) in the standard classes. What class are you using? – Yiannis Lazarides May 1 '12 at 5:48
  • 1
    @StephanLehmke Thanks:) Had some more coffee and posted a MWE to do this. – Yiannis Lazarides May 1 '12 at 6:45

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