7

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 
  \section{Table of Contents, List of Figures, List of Tables and List of Symbols/Abbreviations} 
  Some more text 
\end{document}

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

%
% Table of Contents
%
\renewcommand\contentsname{TABLE OF CONTENTS}
\renewcommand\tableofcontents{% \ev is used for temporary storage of \parskip
\newlength\ev
\setlength{\ev}{\parskip}
\parskip0pt
% A line as 'TABLE OF CONTENTS' must not appear in the
% Table of Contents. Hence we reproduce the \chapter* here except that
% 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}
     \@afterheading
     \@starttoc{toc}%
\parskip\ev}
%
% FBE style TOC does not have bold lines.
\renewcommand\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode
      \advance\leftskip\@tempdima
      \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}}
5
  • Maybe your question is answered here. (Possible duplicate?) Commented Nov 8, 2010 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
    Commented Nov 8, 2010 at 11:56
  • I get this output. Except for the slightly overfull hbox, can you please specify what you don't like about it? Commented Nov 10, 2010 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
    Commented Nov 11, 2010 at 12:40

2 Answers 2

2

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 TeX FAQ.

2

Without a complete example which (beside other informations) would at least show the class you are using you first question can't be answered in a senseful way. Regarding your second question my cristal ball tells me that you should use hyperref with the option linktocpage. See also https://texfaq.org/FAQ-breaklinks

2
  • I tried to improve the question, added an example and a part of the style file. Hope this would be more clear.
    – Basak
    Commented Nov 10, 2010 at 6:58
  • There is no sensible breakpoint, so you get an overful hbox. You could try to add some stretchable space to \rightskip in \l@chapter e.g. \rightskip \@pnumwidth plus 2em Commented Nov 10, 2010 at 10:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .