6

I tried latex code for generating toc suggested by stack exchange in response to my previous query . Still I need small modifications. In the first page of toc, At top middle “TABLE OF CONTENTS” is required and then in the second line 3 column names such as “CHAPTER NO.”, “TITLE” and “PAGE NO.” are required. In subsequent pages only the said second line particulars are required. The same applies to List of tables and List of figures. enter image description here

lockstep
  • 250,273
vivek
  • 359

1 Answers1

6

Here is a modification to Table of Contents with headings on every page that adapts the solution to the three contents elements of a report:

enter image description here

\documentclass{report}
\usepackage[paperheight=30\baselineskip]{geometry}% http://ctan.org/pkg/geometry
\usepackage{tocloft}% http://ctan.org/pkg/tocloft
\usepackage{atbegshi}% http://ctan.org/pkg/atbegshi
\makeatletter
\newcommand{\sectionsandtablesandfigures}{
  \section{First}
  \begin{table}[ht]\caption{A first table}\end{table}\begin{figure}[ht]\caption{A first figure}\end{figure}
  \section{Second}
  \begin{table}[ht]\caption{A second table}\end{table}\begin{figure}[ht]\caption{A second figure}\end{figure}
  \section{Last}
  \begin{table}[ht]\caption{A last table}\end{table}\begin{figure}[ht]\caption{A last figure}\end{figure}
}
\newcommand{\tocheader}{{%
  \bfseries% Font selection
  %\hspace*{\cftchapindent}% Chapter indent
  \makebox[\cftchapnumwidth][l]{Chapter no}% Chapter number heading
  \hfill%
  Title% Title heading
  \hfill%
  \makebox[\@pnumwidth][r]{Page}% Page heading
  \par\kern.5\baselineskip% After heading
  }}
% TABLE OF CONTENTS
\renewcommand{\cftsecdotsep}{\cftnodots}% No dots for \section in ToC
\setlength{\cftbeforetoctitleskip}{0pt}% No skip before ToC title
\setlength{\cftaftertoctitleskip}{0pt}% No skip after ToC title
\renewcommand{\cfttoctitlefont}{\bfseries\Large\hfill}%\contentsname
\renewcommand{\cftaftertoctitle}{\hfill\null\par\kern.5\baselineskip\tocheader\AtBeginShipout{\tocheader}}
\setlength{\cftchapindent}{20pt}% Chapter indent in ToC is 20pt
\begin{lrbox}{\@tempboxa}\bfseries Chapter no\end{lrbox}
\setlength{\cftchapnumwidth}{\dimexpr\wd\@tempboxa-\cftchapindent}% Chapter num width in ToC
\setlength{\cftsecindent}{\wd\@tempboxa}% Section indent in ToC
\setlength{\cftsubsecindent}{\dimexpr\cftsecindent+\cftsecnumwidth}
% LIST OF FIGURES
\renewcommand{\cftfigdotsep}{\cftnodots}
\setlength{\cftbeforeloftitleskip}{0pt}
\setlength{\cftafterloftitleskip}{0pt}
\renewcommand{\cftloftitlefont}{\cleardoublepage\bfseries\Large\hfill}%\listfiguresname
\renewcommand{\cftafterloftitle}{\hfill\null\par\kern.5\baselineskip\tocheader\AtBeginShipout{\tocheader}}
% LIST OF TABLES
\renewcommand{\cfttabdotsep}{\cftnodots}
\setlength{\cftbeforelottitleskip}{0pt}
\setlength{\cftafterlottitleskip}{0pt}
\renewcommand{\cftlottitlefont}{\cleardoublepage\bfseries\Large\hfill}%\listtablesname
\renewcommand{\cftafterlottitle}{\hfill\null\par\kern.5\baselineskip\tocheader\AtBeginShipout{\tocheader}}

\newcommand{\AtBeginShipoutClear}{\gdef\AtBegShi@Hook{}}
\AtEndDocument{%
  \addtocontents{toc}{\protect\AtBeginShipoutClear}%
  \addtocontents{lof}{\protect\AtBeginShipoutClear}%
  \addtocontents{lot}{\protect\AtBeginShipoutClear}%
 }
\makeatother

\begin{document}
\tableofcontents
\listoftables
\listoffigures

\chapter{abcd}\sectionsandtablesandfigures
\chapter{bcde}\sectionsandtablesandfigures
\chapter{cdef}\sectionsandtablesandfigures
\chapter{defg}\sectionsandtablesandfigures
\chapter{efgh}\sectionsandtablesandfigures
\chapter{fghi}\sectionsandtablesandfigures
\chapter{ghji}\sectionsandtablesandfigures
\chapter{hjik}\sectionsandtablesandfigures
\chapter{jikl}\sectionsandtablesandfigures
\chapter{iklm}\sectionsandtablesandfigures
\chapter{klmn}\sectionsandtablesandfigures
\chapter{lmno}\sectionsandtablesandfigures
\chapter{mnop}\sectionsandtablesandfigures
\chapter{nopq}\sectionsandtablesandfigures
\chapter{opqr}\sectionsandtablesandfigures
\chapter{pqrs}\sectionsandtablesandfigures
\chapter{qrst}\sectionsandtablesandfigures
\chapter{rstu}\sectionsandtablesandfigures
\chapter{stuv}\sectionsandtablesandfigures
\chapter{tuvw}\sectionsandtablesandfigures
\chapter{uvwx}\sectionsandtablesandfigures
\chapter{vwxy}\sectionsandtablesandfigures
\chapter{wxyz}\sectionsandtablesandfigures
\end{document}

The following modifications may still be required:

  • If you're using hyperref or bookmark, one should add the relevant information to the contents macros (\tableofcontents, \listoftables and \listoffigures). Currently they're not set as \chapter* the way they're used to.
  • Depending on where your last floats are, it may be required to use atveryend to finalize processing of floats and obtain an accurate ToC/LoT/LoF.
  • Adding the ToC/LoF/LoT to the ToC.
  • Modifying the page styles (which includes the page numbering) surrounding the ToC/LoF/LoT. Easily done using fancyhdr, if need be.
  • Additional indentation of sectional units beyond \subsection to line up properly. However, a base has been established up to \subsection which is easily extendible.
Werner
  • 603,163
  • thank you very much Werner. Your solution works well and new problem arose in the indent numbering of Chapter, section ,subsection and subsubsection. Can you please refer the instructions of the university at page no.44 of 47[ANNEXURE 40] and the link is given below http://www.annauniv.edu/research1/PhDRegulations_2010.pdf
    The solution suggested by you gives same level of indenting for all chapters, sections, subsections and subsubsections. Also, dotted lines are not required. Please suggest.
    – vivek Sep 23 '12 at 04:51
  • @vivek: This is going to take a little while to incorporate. For future reference, include these details from the start. – Werner Sep 23 '12 at 17:14
  • @vivek: I've added some changes. It's still not clear to me how the LoT/LoF (that doesn't have chapters) has to look with a Chapter no reference. As such, I've left it as-is. – Werner Sep 25 '12 at 06:23
  • Thanks Werner. The Solution works fine. i will manipulate those Chapter no. in LoT/LoF as Table no. and Figure no.Thanks. – vivek Sep 25 '12 at 10:14