GeneralFormatting the Table of Contents

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
stephkees
Posts: 6
Joined: Sun Apr 06, 2008 8:49 pm

Formatting the Table of Contents

Post by stephkees »

I am writing my thesis in LaTex and have had to make several adjustments to fit my school's guidelines. The last thing I have left to do is to format my Table of Contents to match theirs.

I need to fix the top margin and change the font size just for the Table of Contents.

If anyone has some hints, please let me know. Thanks so much

(I tried to use tocloft, but when I tried to call the package, I got 58 errors and could not get it to run)

Recommended reading 2024:

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

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

User avatar
Stefan Kottwitz
Site Admin
Posts: 10319
Joined: Mon Mar 10, 2008 9:44 pm

Formatting the Table of Contents

Post by Stefan Kottwitz »

Hi stephkees,

I assume that if you provide a minimal working example you may get faster and more specific help, because we can see the packages used by you, your documentclass and so on.
And you could tell us what exactly needs to be fixed with the top margin and which font sizes need to be changed.

Stefan
stephkees
Posts: 6
Joined: Sun Apr 06, 2008 8:49 pm

Re: Formatting the Table of Contents

Post by stephkees »

OK.

I am using several smaller documents with one main file using inputs. Here is the main file.

\documentclass[12pt, reqno, oneside]{myamsbook}
\pagestyle{plain}
\raggedbottom
%
\def\thechapter{\Roman{chapter}}
\usepackage{amsmath}%
\usepackage{amsfonts}%
\usepackage{amssymb}%
\usepackage{graphicx}%

\numberwithin{equation}{section}
%-----------------------------------------------------------
\usepackage[left=1.5in, right=1in, top=1in, bottom=1in, includeheadfoot]{geometry}
\linespread{2.1}
\begin{document}
\frontmatter

\input{titlepage}
\input{signature}
\input{copyright}
\input{acknowledgement}
\input{abstract}
\tableofcontents

\mainmatter
\setlength{\parindent}{.5in}
\numberwithin{equation}{chapter}
\input{intro}
\input{theory}
\input{literature}
\input{econmodels}
\input{model}
\input{case1}
\input{case2}
\input{case3}
\input{conclusion}

\bibliography{mybib}{}
\bibliographystyle{amsplain}


\end{document}


I started with the amsbook.cls file and already had to make several changes in the way the chapters were set up, so I saved it in a new file named myamsbook. Even before I made those changes, the Table of Contents page had a 2.5in top margin. I need it to be 2in exactly. Also, my table of contents is running onto 2 pages and I would like to change spacing between lines to make it fit 1 page.

Thanks for the feedback



Also, I noticed that my Bibliography is doing the same thing. I would really appreciate any help I can get. My defense is this Wednesday and all I have left to do is the formatting.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10319
Joined: Mon Mar 10, 2008 9:44 pm

Formatting the Table of Contents

Post by Stefan Kottwitz »

Hi stephkees,

one possibility is changing \@starttoc. I took \@starttoc from amsbook.cls, wrote \renewcommand* instead of \def and inserted only one \vspace after the \chapter call with this example:

Code: Select all

\makeatletter
\renewcommand*\@starttoc[2]{%
  \begingroup
  \setTrue{#1}%
  \let\secdef\@gobbletwo \chapter
  \vspace*{-0.5in}
  \let\@secnumber\@empty % for \@tocwrite and \chaptermark
  \ifx\contentsname#2%
  \else \@tocwrite{chapter}{#2}\fi
  \typeout{#2}\@xp\chaptermark\@xp{#2}%
  \@makeschapterhead{#2}\@afterheading
  \parskip\z@skip
  \makeatletter
  \@input{\jobname.#1}%
  \if@filesw
    \@xp\newwrite\csname tf@#1\endcsname
    \immediate\@xp\openout\csname tf@#1\endcsname \jobname.#1\relax
  \fi
  \global\@nobreakfalse \endgroup
  \newpage
}
\makeatother
You might change the parameter of that \vspace until it fits perfectly and compare it with your cls file.

Concerning the spacing of the toc: you can use the setspace package. The package documentation is insinde the setspace.sty file. Example:

Code: Select all

\begin{onehalfspacing}
\tableofcontents
\end{onehalfspacing}
Stefan
stephkees
Posts: 6
Joined: Sun Apr 06, 2008 8:49 pm

Re: Formatting the Table of Contents

Post by stephkees »

That worked great for the Table of Contents. Thanks so much

Is there another quick fix for the Bibliography?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10319
Joined: Mon Mar 10, 2008 9:44 pm

Formatting the Table of Contents

Post by Stefan Kottwitz »

Hi stephkees,

the bibliography calls \chapter, causing the usual chapter margins. For a quick fix let's make a clone of chapter, but with additional \vspace with negative value:

Code: Select all

\makeatletter
\def\bibchapter{%
  \if@openright\cleardoublepage\else\clearpage\fi
  \thispagestyle{plain}\global\@topnum\z@
  \@afterindenttrue
  \vspace*{-0.5in}
  \secdef\@chapter\@schapter}

\renewcommand*\@bibtitlestyle{%
  \@xp\bibchapter\@xp*\@xp{\bibname}%
}
\makeatother
Stefan
stephkees
Posts: 6
Joined: Sun Apr 06, 2008 8:49 pm

Re: Formatting the Table of Contents

Post by stephkees »

You are awesome! I have been on the internet searching for the past 7 hours for both of my formatting problems and you solved them in no time.

I will be definitely coming back to this forum
vblanco
Posts: 1
Joined: Thu Apr 10, 2008 8:50 pm

Re: Formatting the Table of Contents

Post by vblanco »

Hi! I am writting my thesis in the amsbook class and surprisingly the number of the sections appear over the title of each section. The space between the number and the text is negative, and I do not know how to change it. I have been reading that the parameter that controls that space is @pnumwidth, but "renewcommand" does not work. Any idea??

Thanks in advance!!

Victor
User avatar
Stefan Kottwitz
Site Admin
Posts: 10319
Joined: Mon Mar 10, 2008 9:44 pm

Formatting the Table of Contents

Post by Stefan Kottwitz »

Hi Victor,

welcome to the board!

Can you show us some code, that may contain or produce that problem? The best would be a minimal working example containing your preamble and some code, that is compilable and shows the problem, then it's easier for us to give specific help.

Stefan
altec_1
Posts: 1
Joined: Mon Feb 09, 2009 6:34 pm

Formatting the Table of Contents

Post by altec_1 »

Dear Stefan,

I am typesetting my thesis with an un-modified report class. One of the university's guidelines to follow is double spacing is used throughout with the following exceptions

• Captions for Figures/Tables – should be single-spaced (this is ok, the class file takes care).
• Footnotes – should be single-spaced (this is ok, the class file takes care).
• List between entry of TOC is double-spaced, however, the lines (within entry) should be single-spaced.

My problem is the last point previously. Setting double-spaced globally will make the spacing lines within entry is also double-spaced.

... and I don't have a clue how to edit \@starttoc .. and where to put it?

Thanks in advance,


Code: Select all

\documentclass[oneside,a4paper,12pt,doublespace]{report}

%    Include referenced packages here.
\usepackage[a4paper, left=1.5in, top=1.0in, right=1.0in]{geometry}
\usepackage{setspace, amsmath}


%\newtheorem{theorem}{Theorem}[chapter]
%\newtheorem{lemma}[theorem]{Lemma}
%
%\theoremstyle{definition}
%\newtheorem{definition}[theorem]{Definition}
%\newtheorem{example}[theorem]{Example}
%\newtheorem{xca}[theorem]{Exercise}
%
%\theoremstyle{remark}
%\newtheorem{remark}[theorem]{Remark}
%
%\numberwithin{section}{chapter}
%\numberwithin{equation}{chapter}


\renewcommand\contentsname{TABLE OF CONTENTS}
\newcommand\contentsnameLC{Table of Contents}


\begin{document}

%\frontmatter
\pagenumbering{roman}%

\doublespacing

\title{\textsc{Neural Network Adaptive\\
Force and Motion Control\\in the\\Operational Space Formulation}}

\author{\textsc{Dandy}}


\date{}


%\subjclass[2000]{Primary }
%
%\keywords{}

%\begin{abstract}
%\end{abstract}

%    Dedication.  If the dedication is longer than a line or two,
%    remove the centering instructions and the line break.
%\cleardoublepage
%\thispagestyle{empty}
%\vspace*{13.5pc}
%\begin{center}
%  Dedication text (use \\[2pt] for line break if necessary)
%\end{center}
%\cleardoublepage


%    Change page number to 7 if a dedication is present.
%\setcounter{page}{4}

\maketitle

{%
\chapter*{Acknowledgments}\addcontentsline{toc}{chapter}{Acknowledgments}%

I would like to express my gratitude to ......%
\newpage% }

\addcontentsline{toc}{chapter}{Table of Contents}\tableofcontents
\newpage%

{%
\chapter*{Summary}\addcontentsline{toc}{chapter}{Summary}%

It is well-established that dynamically compensated (model-based)
force/motion controller strategy provides better performance than
the standard Proportional-Integral- Derivative (PID) controller.
However, the dynamic model and parameter values, especially for real
robot, are very difficult to identify precisely. Therefore a fast
and cost-effective adaptive method is highly desired.

The main objective in this dissertation deals ultimately with the ...%
\newpage%
}%


\addcontentsline{toc}{chapter}{List of Tables}\listoftables
\newpage%

\addcontentsline{toc}{chapter}{List of Figures}\listoffigures
\newpage%


%\mainmatter
\pagenumbering{arabic}%



%    Include main chapters here.

\chapter{Introduction} \label{ChapterOne}

\section{Background and Problem Definition}

hallo 1.



\chapter{Background Theory: Robot Kinematics and the Operational Space
Formulation} \label{ChapterTwo}

\section{Section: Background Theory: Robot Kinematics and the Operational Space
Formulation}

\newpage

\section{Section: Background Theory: Robot Kinematics and the Operational Space
Formulation}

\newpage

\section{Section: Background Theory: Robot Kinematics and the Operational Space
Formulation}

\newpage


\chapter{Neuro-Adaptive Motion Controller in the Operational Space Formulation} \label{ChapterThree}

\section{Section: Neuro-Adaptive Motion Controller in the Operational Space Formulation}

\newpage

\section{Section: Neuro-Adaptive Motion Controller in the Operational Space Formulation}

\newpage

\section{Section: Neuro-Adaptive Motion Controller in the Operational Space Formulation}

\newpage



\appendix
%    Include appendix "chapters" here.
\include{}

%\backmatter
%    Bibliography styles amsplain or harvard are also acceptable.
\bibliographystyle{amsalpha}
\bibliography{}


%    See note above about multiple indexes.
%\printindex

\end{document}
Post Reply