GeneralLong lines do not wrap around in Table of contents

LaTeX specific issues not fitting into one of the other forums of this category.
uetech
Posts: 4
Joined: Tue Apr 15, 2008 1:30 pm

Long lines do not wrap around in Table of contents

Post by uetech »

Hi friends,

I recently started using latex and while I have faced many problems and found most of the solutions, there is still a problem I cannot fix.

The problem is with the TOC and the List of Figures. The section headings and figure captions are long and so in the TOC and the List of Figures, they should wrap around. Instead, latex displays them on a single line. Pls see figure below:

Image

The code I am using is the following. Many thanks for any kind of help or pointers.

Code: Select all

\documentclass[11pt,a4paper]{diss}
\usepackage{a4,epsfig,exscale,longtable,amsfonts,amsmath,fancyhdr,makeidx,bibunits,hyperref,paralist,tocbibind,subfigure}
\usepackage[dvips]{color}
\usepackage{pifont} % Customizing the itemize list environment

\setlength{\textwidth}{125.0mm} \setlength{\textheight}{195.0mm}
\setlength{\oddsidemargin}{10.0mm}
\setlength{\topmargin}{0.0mm} % <----- book format
\setlength{\baselineskip}{3.75mm} \setlength{\parindent}{5.00mm}

\pagestyle{fancy}

\newfont{\bookfont}{cmbx12 scaled 2500}  % <--------- defining a new font --> \newfont{\bname}{filename scaled scalingfactor*1000}

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\fancyhf{} % delete current setting for header and footer
\fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[LO]{\bfseries\rightmark}
\fancyhead[RE]{\bfseries\leftmark}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}
\addtolength{\headheight}{0.5pt} % make space for the rule
\fancypagestyle{plain}{%
\fancyhead{} % get rid of headers on plain pages
\renewcommand{\headrulewidth}{0pt} % and the line
}

\begin{document}

\parindent 0pt
\frontmatter

\tableofcontents
\pagestyle{empty}

\mainmatter
\pagestyle{fancy}
\addtolength{\parskip}{+0.2cm}

\include{mychapter}

\backmatter
\addtolength{\parskip}{-0.2cm}
\fontsize{10pt}{12pt} %bibliography font size = 10pt

\selectfont
\listoffigures

\bibliographystyle{dissbib}
\bibliography{models}

\vspace{12pt}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10340
Joined: Mon Mar 10, 2008 9:44 pm

Long lines do not wrap around in Table of contents

Post by Stefan Kottwitz »

Hi uetech,

could you please post your diss.cls as attachment? Without it I cannot compile your document to reproduce the problem. It's probably not a standard class.
Your code is not a minimal working example. One may get an impression by reading it and may try to type some additional code to get it compiled and showing the problem, but if you provided a compilable example showing some not-wrapping lines, one could easier give specific help.

Stefan
uetech
Posts: 4
Joined: Tue Apr 15, 2008 1:30 pm

Re: Long lines do not wrap around in Table of contents

Post by uetech »

Hi Stefan_K,

I thank you for your efforts.
I have attached the diss.cls file as well as "mychapter.tex" file. Now the code given in my first post should compile.

Best Regards
Attachments
mychapter.tex
(2.13 KiB) Downloaded 615 times
diss.cls
Custom class file
(26.19 KiB) Downloaded 553 times
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Long lines do not wrap around in Table of contents

Post by gmedina »

I would suggest you to use the hyperref package with the breaklinks option activated; in your preamble, delete hyperref from this list of packages

Code: Select all

\usepackage{a4,epsfig,exscale,longtable,amsfonts,amsmath,fancyhdr,makeidx,bibunits,hyperref,paralist,tocbibind,subfigure}
and add this line after loading all the other packages:

Code: Select all

\usepackage[breaklinks=true]{hyperref}
By the way, you are using problematic and/or obsolete packages such as a4, epsfig,subfigure. The l2tabu document addresses this issue.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
Stefan Kottwitz
Site Admin
Posts: 10340
Joined: Mon Mar 10, 2008 9:44 pm

Long lines do not wrap around in Table of contents

Post by Stefan Kottwitz »

Hi uetech,

I agree with gmedina.
With your attachments I was able to compile (just without makeidx, even added subsections for testing), and the result looks like this:

Image

Probably you should consider updating your used packages.

Stefan
uetech
Posts: 4
Joined: Tue Apr 15, 2008 1:30 pm

Re: Long lines do not wrap around in Table of contents

Post by uetech »

Thanks a lot gmedina and Stefan. The solution works perfectly.

Also thankyou for the information on packages. Actually the template I am using is supplied by my institute, is a very old one and needs to be updated. I will update it soon.

Best Regards
otnemem
Posts: 9
Joined: Mon May 05, 2008 11:29 pm

Long lines do not wrap around in Table of contents

Post by otnemem »

Hi all!

I was going through this post as i have the same problem. Unfortunately this remedy is not working for me. I would be really grateful if someone could give me a hand with this.

The main document is as follows:

Code: Select all

\documentclass [a4paper,12pt,oneside]{book}

\usepackage{float}
\usepackage{harvard}
\usepackage{graphicx}
\usepackage[bottom]{footmisc} %package used to place footnotes at bottom of page
\usepackage[hang,scriptsize,bf]{caption}
\usepackage{multirow}
\usepackage{eurofont}

\renewcommand{\baselinestretch} {1.6} \normalsize

  \setlength{\oddsidemargin}{0.5in}
  \setlength{\evensidemargin}{0.0in}
  \setlength{\topmargin}{0.0in}
  \setlength{\footskip}{0.4in}
  \setlength{\headsep}{0.3in}
  \setlength{\headheight}{0.0in}
  \setlength{\textwidth}{5.6in}
  \setlength{\textheight}{9.3in}

\begin{document}

    \include{preamble}

    \pagenumbering{roman}
    \thispagestyle{empty}
    \tableofcontents
    \thispagestyle{empty}
    \listoffigures
    \thispagestyle{empty}
    \listoftables
    \thispagestyle{empty}

    \pagebreak
    \include{Abbreviations}

    \setlength{\oddsidemargin}{20mm}
    \setlength{\evensidemargin}{40mm}
    \setlength{\topmargin}{0mm}
    \setlength{\footskip}{0.4in}
    \setlength{\headsep}{0.3in}
    \setlength{\headheight}{0.0in}
    \setlength{\textheight}{8.5in}

    \pagenumbering{arabic}
    \include{Introduction}
    \include{Literature}
    \include{Methodology}
    \include{Analysis}
    \include{Conclusions}
    \include{Recommendations}
    \include{Reflections}
    \appendix
    \include{appendixa}
    \include{appendixb}
    \include{appendixc}
    \include{appendixd}

    \setlength{\oddsidemargin}{0.5in}
    \setlength{\evensidemargin}{0.0in}
    \setlength{\topmargin}{0.0in}
    \setlength{\footskip}{0.4in}
    \setlength{\headsep}{0.3in}
    \setlength{\headheight}{0.0in}
    \setlength{\textwidth}{5.6in}
    \setlength{\textheight}{9.3in}

    \nocite{*}

    \addcontentsline{toc}{chapter}{References}
    \bibliography{References}
    \bibliographystyle{agsm}
    \thispagestyle{empty}

\end{document}

Thanks again in advance for all!
User avatar
Stefan Kottwitz
Site Admin
Posts: 10340
Joined: Mon Mar 10, 2008 9:44 pm

Long lines do not wrap around in Table of contents

Post by Stefan Kottwitz »

Hi otnemem,

welcome to the LateX Community board!
I cannot compile your main document because I don't have the files that you are including. If I compile it without those files I cannot see the unwanted behaviour. Perhaps you could insert some lines (\chapter, \section ?) so that we can see what's meant. A minimal working example should be compilable and showing the problem. See here for more information. Usually compilable code quickly leads to a solution.

Stefan
LaTeX.org admin
otnemem
Posts: 9
Joined: Mon May 05, 2008 11:29 pm

Long lines do not wrap around in Table of contents

Post by otnemem »

Hi there! thank for your reply... :)

I am taking off all the related files and just created a toc entry that is long enough not to wrap properly. The code is this...hope it's more indicative:

Code: Select all

\documentclass [a4paper,12pt,oneside]{book}

\usepackage{float}
\usepackage{harvard}
\usepackage{graphicx}
\usepackage[bottom]{footmisc} %package used to place footnotes at bottom of page
\usepackage[hang,scriptsize,bf]{caption}
\usepackage{multirow}
\usepackage{eurofont}

\renewcommand{\baselinestretch} {1.6} \normalsize

  \setlength{\oddsidemargin}{0.5in}
  \setlength{\evensidemargin}{0.0in}
  \setlength{\topmargin}{0.0in}
  \setlength{\footskip}{0.4in}
  \setlength{\headsep}{0.3in}
  \setlength{\headheight}{0.0in}
  \setlength{\textwidth}{5.6in}
  \setlength{\textheight}{9.3in}

\begin{document}

    \pagenumbering{roman}
    \thispagestyle{empty}
    \tableofcontents
    \setlength{\oddsidemargin}{20mm}
    \setlength{\evensidemargin}{40mm}
    \setlength{\topmargin}{0mm}
    \setlength{\footskip}{0.4in}
    \setlength{\headsep}{0.3in}
    \setlength{\headheight}{0.0in}
    \setlength{\textheight}{8.5in}

    \section{The relationship between economic instruments and road transport policies}

    \setlength{\oddsidemargin}{0.5in}
    \setlength{\evensidemargin}{0.0in}
    \setlength{\topmargin}{0.0in}
    \setlength{\footskip}{0.4in}
    \setlength{\headsep}{0.3in}
    \setlength{\headheight}{0.0in}
    \setlength{\textwidth}{5.6in}
    \setlength{\textheight}{9.3in}

    \nocite{*}

    \addcontentsline{toc}{chapter}{References}
    \bibliography{References}
    \bibliographystyle{agsm}
    \thispagestyle{empty}

\end{document}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10340
Joined: Mon Mar 10, 2008 9:44 pm

Long lines do not wrap around in Table of contents

Post by Stefan Kottwitz »

Hi otnemem,

I've tested your example without changes, the output looks like this:
contents.png
contents.png (11.97 KiB) Viewed 20490 times
Do you get different wrapping?

Stefan
LaTeX.org admin
Post Reply