# TOC line indent and break problem

I have long chapter and section titles in my document, so titles in the table of contents do not fit into one line. I have two problems regarding with this:

1. When the second line starts, i need to indent it to the right a bit, but i do not know how.
2. When a chapter title is too long to fit in one line, the line continues till the margin of the page numbers. I need this line to cut before the page number box, leaving this space empty and continue with the second line.

Here is an example:

\documentclass[12pt]{report}
\usepackage{styles/fbe_tez}
\begin{document}
\tableofcontents
\chapter{FORMAT OF DISKETTES/CD CONTAINING COMPUTER SOFTWARE}
Some text here
Some more text
\end{document}


The style package is provided to me and here is the part relevant to the toc.

%
%
\renewcommand\tableofcontents{% \ev is used for temporary storage of \parskip
\newlength\ev
\setlength{\ev}{\parskip}
\parskip0pt
% no entry is put into the toc file.
\clearpage  \global\@topnum\z@
\@afterindenttrue
\begin{center}
{ \normalfont
\interlinepenalty\@M
\large \bfseries  \contentsname\par\nobreak
\vskip21pt \vskip0.8\baselineskip
}\end{center}
\@starttoc{toc}%
\parskip\ev}
%
% FBE style TOC does not have bold lines.
\renewcommand\l@chapter[2]{%
\ifnum \c@tocdepth >\m@ne
\setlength\@tempdima{1.5em}%
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\leavevmode
\hskip -\leftskip
#1\nobreak\leaders\hbox{$\m@th \mkern \@dotsep mu.\mkern \@dotsep mu$}\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
\penalty\@highpenalty
\endgroup
\fi}
%
% The spacing of the TOC lines has been redefined.
\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.em}}
\renewcommand*\l@subsection{\@dottedtocline{2}{3.8em}{2.9em}}
\renewcommand*\l@subsubsection{\@dottedtocline{3}{7em}{3.8em}}
\renewcommand*\l@paragraph{\@dottedtocline{4}{11.1em}{4.7em}}
\renewcommand*\l@subparagraph{\@dottedtocline{5}{16.1em}{5.7em}}

-
Maybe your question is answered here. (Possible duplicate?) –  Hendrik Vogt Nov 8 '10 at 9:06
It looks similar but i do not have any problem with my page numbers, they are all placed right. However, for the 2nd example given there my second line is shifted to left, and when the title is broken into two lines, the first line continues till where the page number should have been. –  Basak Nov 8 '10 at 11:56
I get this output. Except for the slightly overfull hbox, can you please specify what you don't like about it? –  Hendrik Vogt Nov 10 '10 at 15:11
Actually this is the result i have intended to get. So, I think there is a conflict in my sty file which can be found here: dl.dropbox.com/u/9471314/fbe_tez.sty –  Basak Nov 11 '10 at 12:40
–  andz Aug 3 '11 at 13:44

You could use the tocloft package to customize the table of contents. It provides commands to modify indentation and page number width. Have a look at the documentation (texdoc tocloft or follow the link to CTAN), search for the macros \cftXindent and \cftXnumwidth for instance.
Without tocloft it may be a bit harder, for instance by adjusting \@pnumwidth like mentioned in The format of the Table of Contents in the UK TeX FAQ.