Text FormattingModifying the Table of Contents

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
s.david
Posts: 43
Joined: Thu Sep 10, 2009 5:22 pm

Modifying the Table of Contents

Post by s.david »

Hello,

How can I do something like this:

..................TABLE OF CONTENTS................

TITLE.....................................PAGE
CHAPTER ONE: ..............................23

Specifically, how can I center the title TABLE OF CONTENTS and add the TITLE address in the left and PAGE address in the right.

Note: For the title TABLE OF CONTENTS I am using the \chapter command, i.e.: \chapter{\contentsname}

Thanks in advance

Recommended reading 2024:

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

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

mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

Re: Modifying the Table of Contents

Post by mas »

Have you tried using the tocloft package? The documentation is quite extensive to help you achieve what you want.

Regards,

sridhar

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
s.david
Posts: 43
Joined: Thu Sep 10, 2009 5:22 pm

Modifying the Table of Contents

Post by s.david »

mas wrote:Have you tried using the tocloft package? The documentation is quite extensive to help you achieve what you want.

Regards,

sridhar
Thank you sridhar for replying.

Actually, I am not professional in Latex, and I don't know how to handle and create my own layout.

I just discussed my master thesis and the Faculty of Graduate Study needs me to make some modifications in order for my thesis to be accepted and the certificate to be generated. However, these requirements make it difficult for me. At the same time, it is too late to return to the Microsoft Word because my thesis is already written in Latex. I think it is more efficient to continue in Latex than using the Word at this point.

So, any help will be highly appreciated.

Best regards
adrian
Posts: 8
Joined: Thu Nov 12, 2009 5:24 pm

Re: Modifying the Table of Contents

Post by adrian »

Which document class are you using? Memoir, or something else?
Presumably you want spaces where the '.' symbols appear in your original
e-mail?
tocloft will not change the overall layout, as I understand it.
s.david
Posts: 43
Joined: Thu Sep 10, 2009 5:22 pm

Modifying the Table of Contents

Post by s.david »

adrian wrote:Which document class are you using? Memoir, or something else?
Presumably you want spaces where the '.' symbols appear in your original
e-mail?
tocloft will not change the overall layout, as I understand it.
Yes, I am using the Memoir class. I really need this very soon. The '.' symbols are just to illustrate my point here where it is not allowed to do more than one space.

Thanks in advance
daleif
Posts: 199
Joined: Wed Nov 19, 2008 12:46 am

Re: Modifying the Table of Contents

Post by daleif »

at the moment I don't think there is any package that provides the Title and Page headers for the titles and page number 'columns'

I'm thinking about adding such a feature to memoir, but how do you add it after a page break in a long toc?

How long is the ToC? We might be able to hack something.
s.david
Posts: 43
Joined: Thu Sep 10, 2009 5:22 pm

Modifying the Table of Contents

Post by s.david »

daleif wrote:at the moment I don't think there is any package that provides the Title and Page headers for the titles and page number 'columns'

I'm thinking about adding such a feature to memoir, but how do you add it after a page break in a long toc?

How long is the ToC? We might be able to hack something.
It would be great if there is a package provides such options. However, as I know, you can tail features you want using Latex. Unfortunately, during my working on my thesis, I have focused on the contents and contribution more than the format and layout. Anyway, the ToC in my thesis is two pages long.

Best regards
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Modifying the Table of Contents

Post by meho_r »

Let's see if this helps. I used \book sectioning command provided by memoir class to typeset fake "Title" and "Page" entries in TOC. I choose it since it is not used that much.

Note that this is manual approach and not very elegant, but since your TOC isn't that long, it may be used. Another way could be using headers for this purpose (with fancyhdr or memoir's own way); this way you don't have to do any manual work. However, if you're already using header (e.g. for typesetting "Table of contents" and/or page numbers), then this manual approach may be easier.

Here's an example code:

Code: Select all

\documentclass{memoir}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}

%%%%%%% Setting contents name

\renewcommand{\printtoctitle}[1]{\hfill\Huge\bfseries TABLE OF CONTENTS\hfill\vspace{1em}}% Setting custom contents title; change \vspace as you like


%%%%%%% Book entry

\renewcommand{\booknumberline}[1]{}% removes book number
\renewcommand{\cftbookformatpnum}[1]{}% removes book page number in TOC
\renewcommand{\cftbookfont}{\normalfont\Large}% formatting

\newcommand{\addtitlepage}{\addcontentsline{toc}{book}{TITLE\hfill PAGE}}% a new command to add in text where "Title" and "Page" should appear in TOC


\usepackage{blindtext}

\begin{document}

\addtitlepage% adding "Title" and "Page" in TOC at the beginning

\addcontentsline{toc}{chapter}{TABLE OF CONTENTS}% adds "Table of Content" entry in TOC

\tableofcontents*% use stared version of TOC; previous line adds customized entry in TOC


\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument

\addtitlepage% added a manual entry posing as "Title" and "Page" in TOC; I added it here because after 8th chapter there is a pagebreak in TOC
\Blinddocument
\Blinddocument
\end{document}
BTW, I don't see any reason to use \chapter{\contentsname}.
Post Reply