Page LayoutTable of Contents Chapter Titles, Dots

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
ia1
Posts: 4
Joined: Sat Feb 20, 2010 10:56 pm

Table of Contents Chapter Titles, Dots

Post by ia1 »

Hi,

I need to format my table of contents so that it has a series of dots between chapter titles and the page each chapter appears on. Currently only the subsections in my table of contents have these dots.

Because I'm required to use a pre-made class file (which I can alter, to a small extent), I think I'm not able to use the package tocloft without massive modification, as this package seems to override much of the page formatting the required class file specifies. (For instance it changes line spacing, doesn't put the toc on a new page, leads to bold chapter titles having bold lines of dots, and doesn't add dots after the "References" entry.) The formatting of my toc is ok aside from the said issue, so if possible I want to make as few changes as possible.

The relevant code for the table of contents in the class file, as far as I can see, is:

Code: Select all

\newcommand{\th@ToCpage}{%
	\if@shortToC%
	    \@THshortChaptertrue%
	    \typeout{Making Short ToC...}%
	\fi%
	\@thInHeadingfalse%
	    \thispagestyle{plain}%
	{\pagestyle{plain}%
	\doublespacing%
	\tableofcontents}%
}
Is there any way I can alter this to also add dots after chapter titles?

If it would be helpful for me to paste more, there's plenty.
Thanks...

Also, someone had a similar problem but they were using the amsbook class, but I don't know how compatible the answer is, as it doesn't work for me. http://www.latex-community.org/forum/vi ... =47&t=6636.


In case anyone else needs these dots after chapter titles, but doesn't have other formatting constraints, a command is:

Code: Select all

\usepackage{tocloft}
\renewcommand{\cftchapdotsep}{\cftdotsep}
Last edited by ia1 on Mon Feb 22, 2010 12:54 am, edited 2 times in total.

Recommended reading 2024:

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

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

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Table of Contents Chapter Titles, Dots

Post by gmedina »

Hi,

in order to suggest the appropriated modification, we would need to see the definition of the comand in charge of actually typesetting the chapter entries in the ToC (for example, in the standard document classes book and report, that command is \l@chapter).

Attach to your next post the complete .cls file that you are using and perhaps someone will have the time to go through it and provide the necessary changes. Another option would be to contact directly the author of the class file.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
ia1
Posts: 4
Joined: Sat Feb 20, 2010 10:56 pm

Re: Table of Contents Chapter Titles, Dots

Post by ia1 »

Here's the class file.
Attachments
thesis.cls
(59.85 KiB) Downloaded 729 times
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Table of Contents Chapter Titles, Dots

Post by localghost »

A minimal working example (MWE) is essential. Especially in this case because there are some critical points.
  • The class file has a wrong name. It is actually called »umassdthesis.cls«. Seems to be a derivate of the umthesis class
  • There are sudden error messages because some parts have not been specified in the example I tested. But there are no real errors so the messages should only be warnings. Otherwise they are irritating.
To get the desired result insert the following lines into your preamble.

Code: Select all

\makeatletter
\renewcommand*\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\normalfont\leaders\hbox{$\m@th
        \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
        mu$}\hfill\nobreak\hb@xt@\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi}
\makeatother
This redefines the \l@chapter command mentioned by gmedina in his post above.


Best regards and welcome to the board
Thorsten¹
ia1
Posts: 4
Joined: Sat Feb 20, 2010 10:56 pm

Table of Contents Chapter Titles, Dots

Post by ia1 »

Wow, that works perfectly except for one issue. (Thanks! :D) The References section, for the bibliography, appears at the end of the table of contents and is the only full line without dots.

Here's a current MWE:

Code: Select all

\documentclass[12pt,modernstyle]{umassdthesis}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{graphicx} %trying without [dvips]{graphicx}
\usepackage{subfigure}
\usepackage{multirow,hhline,dcolumn} % useful commands for Tables
\usepackage{epstopdf}
% user defined commands
\newcommand{\linefrac}[2]{\raisebox{.6ex}{#1}/\raisebox{-0.6ex}{#2}}

\makeatletter
\renewcommand*\l@chapter[2]{%
\ifnum \c@tocdepth >\m@ne
\addpenalty{-\@highpenalty}%
\vskip 1.0em \@plus\p@
\setlength\@tempdima{1.5em}%
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\leavevmode \bfseries
\advance\leftskip\@tempdima
\hskip -\leftskip
#1\nobreak\normalfont\leaders\hbox{$\m@th
\mkern \@dotsep mu\hbox{.}\mkern \@dotsep
mu$}\hfill\nobreak\hb@xt@\@pnumwidth{\hss #2}\par
\penalty\@highpenalty
\endgroup
\fi}
\makeatother

\title{title}
\author{first}{last}
\dept{the}{dept}
\college{univ of}{here}
\conferraldate{pretty}{soon}
\advisor{somebody}{smart}%
{}
\readerone{}{}%
{}
\readertwo{}{}%
{}
\graddirector{}
\deptchair{}
\collegedean{}
\gradstudies{}
\degree{fancy}{degree}
\abstract[short]{}
\dedication{}
\preface[acknowledgements]{}
\begin{document}%
\chapter{Introduction}
\section{Section}
\subsection{Subsection}
%...
\chapter{Conclusions}
\bibliographystyle{unsrt}

% You can type directly into this file or make use of the LaTeX
% \input{filename} to read the contents of the file filename.tex.
% This later method is a good way to logically separate the material.
% At the end we put the references. These are single-spaced rather than
% double-spaced like the rest of the thesis text.
\begin{singlespace}
\bibliographystyle{unsrt}
%\inputbib{bib.tex}
\begin{thebibliography}{99}
\bibitem{1} bibliography item 1
\bibitem{2} bibliography item 2
\bibitem{3} bibliography item 3
\end{singlespace}
\end{document}
Last edited by ia1 on Sun Feb 21, 2010 11:54 pm, edited 1 time in total.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Table of Contents Chapter Titles, Dots

Post by localghost »

Please use the code environment of the forum software to tag source code as such. This is essential to keep a post clear and legible.

The class adds the bibliography heading as part to the ToC. So we have to redefine also the \l@part command. See code below for all the necessary redefinitions. Note that it also includes the code from my last reply.

Code: Select all

\makeatletter
\renewcommand*\l@part[2]{%
  \ifnum \c@tocdepth >-2\relax
    \addpenalty{-\@highpenalty}%
    \addvspace{2.25em \@plus\p@}%
    \setlength\@tempdima{3em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      {\leavevmode
       \large \bfseries #1\nobreak\normalfont\leaders\hbox{$\m@th
        \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
        mu$}\hfill\nobreak \hb@xt@\@pnumwidth{\hss #2}}\par
       \nobreak
         \global\@nobreaktrue
         \everypar{\global\@nobreakfalse\everypar{}}%
    \endgroup
  \fi}
\renewcommand*\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\normalfont\leaders\hbox{$\m@th
        \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
        mu$}\hfill\nobreak\hb@xt@\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi}
\makeatother
ia1
Posts: 4
Joined: Sat Feb 20, 2010 10:56 pm

Re: Table of Contents Chapter Titles, Dots

Post by ia1 »

It seems to work perfectly. Much thanks! I've also edited my previous posts with the ./code modifiers. :D
Post Reply