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.

In my LaTeX code I add the line

\tableofcontents

And begging of each chapter i have these lines.

\renewcommand{\vspace}[2]{}\chapter{ }
{\huge\bf Introduction}
\addcontentsline{toc}{chapter}{Introduction}

When i compile my code it shows

1                                                                                 5
    Introduction                                                                  5
        1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . .    5
2                                                                                 6
    Computing                                                                     6
        2.1 Computing type . . . . .... . . . . . . . . . . . . . . . . . . . . . 6

Like this,

But I want to get the "Chapter" name to in front of the number like this.

Chapter 1 
    Introduction 
        1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5
Chapter 2 
    Computing 
        2.1 Computing type . .  . . . . . . . . . . . . . . . . . . . . 6

How can I do that?

share|improve this question
    
use the tocloft package (or the memoir class) it has featues to add such names –  daleif Sep 14 '12 at 12:05
    
I tried it but it end up with same result. –  Team Sep 14 '12 at 12:11
    
@Team, how was the code for trying that? –  zeroth Sep 14 '12 at 12:21
6  
Never redefine \vspace! –  egreg Sep 14 '12 at 12:39
1  
show 3 more comments

1 Answer

You can use the tocloft package to do this: a redefinition of \cftchappresnum allows to add \chaptername before the sectional unit number (this requires increasing the length \cftchapnumwidth). Redefining \cftchapaftersnumb you can add a line break after the sectional number and some negative horizontal spacing to achieve the desired alignment. A little example:

\documentclass{book}
\usepackage{tocloft}

\newlength\mylen
\renewcommand\cftchappresnum{\chaptername~}
\settowidth\mylen{\bfseries\cftchappresnum\cftchapaftersnum}
\renewcommand\cftchapaftersnumb{\\*\hspace*{-\mylen}}
\addtolength\cftchapnumwidth{\mylen}

\begin{document}

\tableofcontents
\chapter{Introduction}
\section{Overview}
\chapter{Computing}
\section{Computing type}

\end{document}

enter image description here

As egreg points out in his comment, it is not a good idea to redefine \vspace. If you want to redefine the formatting for the sectional units and you are using a standard document class, you can use the titlesec package.

share|improve this answer
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.