I'm having problems with customizing the table of contents of my thesis according to my university's requirements.
The main problem is with the dotting in the chapter and section leaders when using the report class along with the tocloft package. I need to have the dotting in the normal chapter leaders but not in the early 'chapters' like 'abstract' 'preface' and such.
Also I can't get the dotting and page numbers to align correctly. I've tried to change the box size for the page numbers but it doesn't work as I would like.
Here's a picture of how it should look: ( Don't mind the text, it's from the thesis guide written in Finnish ) And here's how my attempt looks: ( all the formatting not related to the problems removed ) I'm using '\chapter*' for the early chapters that should not have dotting in their leaders. The dotting for normal chapter leaders is otherwise good but the page numbering gets aligned to left when there are at least 10 pages.
I have tried to adjust the 'pnumwidth' to get the alignment correctly, but when I give the numbers more space, the dots won't reach all the way for the chapters and sections for early pages, as seen below: Here is a working code for the problem. ( I tried to remove all the unnecessary formatting not related to my problems )
Code: Select all
\documentclass[a4paper, 12pt]{report}
\usepackage{times}
\usepackage{tocloft}
\makeatletter
\renewcommand{\contentsname}{TABLE OF CONTENTS}
\renewcommand{\cftchapfont}{\normalfont}
\renewcommand{\cftchappagefont}{\normalfont}
\renewcommand{\cftdotsep}{1}
\renewcommand{\cftchapleader}{\cftdotfill{\cftsecdotsep}}
% Try to remove margin between leader dots and page numbers:
\cftsetpnumwidth{12pt}
\renewcommand{\chapter}{ \newpage
\@startsection {chapter}{0}{0mm}{0mm}{\baselineskip}
{\normalfont\large\bfseries\centering} }
\makeatother
\begin{document}
\addtocontents{toc}{\protect\contentsline{chapter}{ABSTRACT}{} }
\chapter*{ABSTRACT}
\newpage
\addtocontents{toc}{\protect\contentsline{chapter}{TABLE OF CONTENTS}{} }
\tableofcontents
\addtocontents{toc}{\protect\contentsline{chapter}{FOREWORD}{} }
\chapter*{FOREWORD}
\addtocontents{toc}{\protect\contentsline{chapter}{ABBREVIATIONS}{} }
\chapter*{ABBREVIATIONS}
\chapter{FIRST CHAPTER}
\section{First section}
\subsection{Fist subsection}
\section{Second section}
% Dummy pages to get two digit page numbers to TOC
\newpage 1 \newpage 2 \newpage 3 \newpage 4 \newpage 5
\chapter{SECOND CHAPTER}
\chapter{THIRD CHAPTER}
\end{document}
Hopefully this haven't been asked multiple times, I couldn't find posts with the same problem. I'm fairly new to LaTeX, so please tell if there's some obvious faults or if it's just generally bad code.
Br,
Pekka
// Edit: Solved, see 2nd and 4th reply.