Text FormattingProblems with ToC in custom Class

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Sanjeevi_S
Posts: 4
Joined: Sun Jul 22, 2012 2:51 am

Problems with ToC in custom Class

Post by Sanjeevi_S »

Hi everyone,

I'm trying to write my dissertation using LaTeX. I downloaded a class file provided by my university. The \tableofcontents command was defined in the class file as follows:

Code: Select all

\def\tableofcontents{
\newpage
   \let \tempp \topskip
   \topskip 1em
\tocspace
\chapter*{\vspace*{-2em}TABLE OF CONTENTS\markright{CHAPTER}}
  {\vskip -1em CHAPTER \hfill Page \vspace{0.5ex}\\}
  \thispagestyle{myheadings}
  \@starttoc{toc}
\doublespace  \topskip \tempp}
As the margins of the first page of the table of contents were unsuitable for me, I found some help on a LaTeX forum and redefined \chapter* as follows:

Code: Select all

\setlength{\headheight}{26pt}
\makeatletter
\def\@makeschapterhead#1{
  {\parindent \z@ \centering
    \normalfont
    \interlinepenalty\@M
    #1\par\nobreak
    \vskip 30\p@
  }}
\makeatother
The first page of the table of contents looks exactly like I want it to. However, the second page has a different top margin (the text is much higher than I want it to be). I also use the following for spacing in \tableofcontents:

Code: Select all

\def\l@section{\@dottedtocline{1}{7em}{3em}}
\def\l@subsection{\@dottedtocline{2}{9em}{3em}}
\def\l@subsubsection{\@dottedtocline{3}{11em}{1.5em}}
\def\l@paragraph{\@dottedtocline{4}{13em}{1.5em}}
\def\l@subparagraph{\@dottedtocline{5}{14em}{1.5em}}
I would like the second page of the table of contents to have the same margin settings as the first page. Could someone help me with this please?

Thanks in advance!
Last edited by localghost on Sun Jul 22, 2012 12:26 pm, 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.

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Problems with ToC in custom Class

Post by cgnieder »

Could you make these various code snippets into a Infominimal working example that shows the undesired behaviour?

Regards
site moderator & package author
Sanjeevi_S
Posts: 4
Joined: Sun Jul 22, 2012 2:51 am

Problems with ToC in custom Class

Post by Sanjeevi_S »

The following is a minimal working example:

Code: Select all

\documentclass{eethesis}
\usepackage[left=1.4in,right=1in,top=1.25in,bottom=1.25in]{geometry}
\usepackage{sectsty,titlesec}

\makeatletter
\def\@makechapterhead#1{%
  %\vspace*{50\p@}%
  {\parindent \z@ \centering \normalfont
    \ifnum \c@secnumdepth >\m@ne
        \@chapapp\space \thechapter %add things like \large, \bfseries at the beginning of this line
        \par\nobreak
        \vskip 20\p@
    \fi
    \interlinepenalty\@M
    #1\par\nobreak %add things like \large, \bfseries at the beginning of this line
    \vskip 40\p@
  }}
\makeatother

\makeatletter
\def\@makeschapterhead#1{%
  %\vspace*{-22\p@}%
  {\parindent \z@ \centering
    \normalfont
    \interlinepenalty\@M
    #1\par\nobreak %add things like \large, \bfseries at the beginning of this line
    \vskip 30\p@
  }}
\makeatother

\begin{document}
\pagenumbering{roman}
\setcounter{tocdepth}{2}
\pagestyle{headings}
\setlength{\headheight}{26pt}
\setlength{\headsep}{60pt}
\tableofcontents
\setlength{\headheight}{12pt}
\setlength{\headsep}{42pt}
\clearpage
\pagenumbering{arabic}
\setlength{\headheight}{12pt}
\pagestyle{myheadings}
\chapter{chapter}
\section{section}
\subsection{sub}
\subsection{sub}
\subsection{sub}
\section{section}
\subsection{sub}
\subsection{sub}
\subsection{sub}
\section{section}
\subsection{sub}
\subsection{sub}
\subsection{sub}
\chapter{chapter}
\section{section}
\subsection{sub}
\subsection{sub}
\subsection{sub}
\section{section}
\subsection{sub}
\subsection{sub}
\subsection{sub}
\section{section}
\subsection{sub}
\subsection{sub}
\subsection{sub}
\chapter{chapter}
\section{section}
\subsection{sub}
\subsection{sub}
\subsection{sub}
\section{section}
\subsection{sub}
\subsection{sub}
\subsection{sub}
\section{section}
\subsection{sub}
\subsection{sub}
\subsection{sub}
\chapter{chapter}
\section{section}
\subsection{sub}
\subsection{sub}
\subsection{sub}
\section{section}
\subsection{sub}
\subsection{sub}
\subsection{sub}
\section{section}
\subsection{sub}
\subsection{sub}
\subsection{sub}
\end{document}
I had to use a lot of chapters and sections for the toc to go to two pages. I've attached the related class and style file required to compile the document. The \tableofcontents command is defined in the file eethesis.cls. What I need is to have the "CHAPTER page" line in the second page of the toc to be at the same level as the "TABLE OF CONTENTS" line in the first page. I also need the spacing between the "CHAPTER page" line and the table of contents to be the same in both pages. Any help is appreciated!
Attachments
eethetitle.sty
(9.29 KiB) Downloaded 190 times
eethesis.cls
(51.23 KiB) Downloaded 195 times
eethe12.sty
(21.71 KiB) Downloaded 203 times
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Problems with ToC in custom Class

Post by cgnieder »

This is some odd definition of the table of contents. It seems to assume that the ToC is not longer than one page:

Code: Select all

\def\tableofcontents{
    \newpage
       \let \tempp \topskip
       \topskip 1em
    \tocspace
    \chapter*{\vspace*{-2em}TABLE OF CONTENTS\markright{CHAPTER}}
      {\vskip -1em CHAPTER \hfill Page \vspace{0.5ex}\\}% <= first line after the chapter entry, not intended to be repeated on another page...
      \thispagestyle{myheadings}% sets the headings for one page only
      \@starttoc{toc}
    \doublespace  \topskip \tempp}
The simplest thing would be not to repeat the “CHAPTER ..... page” line and to replace \thispagestyle{myheadings} with \pagestyle{myheadings}. Then the ToC at least would have a halfway consistent look. I have some vague idea how to obtain the output you like but have to try first if it works… I am not too optimistic right now.

Maybe some expert will drop in with an idea…

Regards
site moderator & package author
Sanjeevi_S
Posts: 4
Joined: Sun Jul 22, 2012 2:51 am

Re: Problems with ToC in custom Class

Post by Sanjeevi_S »

Thanks for the reply. It works like you said, and helps partly. Removing the redefinition of the "CHAPTER page" line and changing it to \pagestyle{headings} makes the "CHAPTER page" line appear at the same level on the two pages. However, there are two problems:

1. The "Table of Contents" title now appears below the "CHAPTER page" line

2. The spacing issue in the second page of ToC is still not resolved.

I'm currently trying to play with the \headheight and \headsep commands to see if some sort of adjustment can be made.
Sanjeevi_S
Posts: 4
Joined: Sun Jul 22, 2012 2:51 am

Problems with ToC in custom Class

Post by Sanjeevi_S »

This helped a bit more.

Code: Select all

\addtocontents{toc}{CHAPTER ~\hfill Page\par}
Now, I have the "CHAPTER Page" line exactly where I want in the first page, but don't know how to put it in the second page yet.
Post Reply