I need to make my Table of Contents entries like this: (With the heading table of contents at the center).

enter image description here

The things I was able to achieve till now:

i) Modifying the title of ToC
ii) Modifying or adding subtitles

Now How do I insert a table and put all these entries in it. In the ordinary ToC, Expt. No,Name,Page will be there but how do I insert the date automatically?

The code in which I want to embed this:

\begin{tikzpicture}[remember picture, overlay]
\node[anchor=center,inner sep=0pt] at ($(current page.north west) + (17.3cm,-1.5cm)$) {\thepage};

\addtocounter{chapter}{1}   %% do this at the start of each expt.
\pagestyle{empty}   %% this is needed
\begin{tikzpicture}[remember picture, overlay]
\node[anchor=center,inner sep=0pt,font=\Large\bfseries] at ($(current page.north west) + (4.7cm,-2.7cm)$) {\thechapter};
\node[anchor=center,inner sep=0pt,font=\Large\bfseries] at ($(current page.north) + (0cm,-2.7cm)$) {Study of Oracle};
\node[anchor=center,inner sep=0pt,font=\Large\bfseries] at ($(current page.north west) + (18cm,-2.7cm)$) {5.04.2014};

How do I do that?

Here is my MWE:

\renewcommand\contentsname{Table of Contents}

    \addtocontents{toc}{~\textbf{Name of the Experiment}}
 \chapter{Hello World}

And this is its output:

![enter image description here][2]

Also, when I compile my code, I get an error:

enter image description here

But I am able to view the pdf. What should I do to make my ToC as per my requirements?

Dont know why my 2nd image is not getting uploaded.

The ToC will contain only chapter names (no sections or subsections), the date it was written and its page number and the chapter number as expt.no. I am using the book class.For Hyperlinks, I have added the page numbers as references already in my code.

  • I would generate commands into a bright new file which would be loaded in next runs of TeX. A complete rewriting or setting of commands needed for ToC may not be an easy task. – Malipivo Apr 6 '14 at 6:55
  • Your addtocontents{toc} will not bring you any closer to achieving your goal. And what about the regular chapter, section, subsection titles, are they supposed to end up in the table? Are the experiments names also \section's names? do you need your table to be hyperlinked? One can achieve all you want with etoc (combining techniques from its manual) but the "simplest" would indeed be to forget about misusing the TOC and rather use an auxiliary file to prepare there the table. – user4686 Apr 6 '14 at 7:00
  • You will have to tell us more about how the "experiment" entries are generated. Are they like theorems, or something else? Also, do you maybe want to generate a separate listing of the experiments in a ToC-like listing (say, "List of Experiments"), or do you want the experiments listed in the main ToC along with chapters, sections, etc.? – Mico Apr 6 '14 at 7:00
  • Question edited @jfbu – subham soni Apr 6 '14 at 7:11
  • This is still not clear. Thus, the whole TOC is one table, right? each experiment is associated to one chapter, and each chapter to one experiment? – user4686 Apr 6 '14 at 7:13

I have left the Remarks column empty. The method requires the following mark-up:


One could extend the mechanism to handle Remarks. Here \EXP definition is initially

\protected\def\EXP #1#2{#2 (#1)}

and this is how chapter titles will appear in the document. It is redefined internally by the TOC typesetting code.

It is assumed that there are no \part (but allowing them is just a matter of adding \etocsetlevel{part}{1} for example inside \TOCofexperiments macro) but \section, and \subsection are allowed. It is allowed to use the standard \tableofcontents additionally to the TOCofexperiments. The image is a screen capture from a pdf viewer showing that the entries are links. (one could also make the page a link, either via option linktoc=all of hyperref or modifying a bit the use of the etoc commands; and one could make the date a link too).

experiment table toc

\documentclass [a4paper]{book}

\newcommand*\appendtotok[2]{% #1=toks variable, #2=macro, expands once #2
    {\expandafter\the\expandafter #1#2}}

  \toks0 \expandafter{\etocthelinkednumber}% expt number
  \edef\TEMP {\etocthename}\toks2 \expandafter{\TEMP}%% expt date and name
  \toks4 \expandafter{\etocthelinkedpage}%   expt page
                      \noexpand\strut\the\toks0 &
                                     \the\toks2 &
                                     \the\toks4 &\noexpand\\ }%

      {\PrepareChapter \appendtotok\toctabletok\toctablepiece}
    {\def\EXP ####1####2{\unexpanded{####1} & 
                                     TABLE OF CONTENTS}\\
     Expt. No & Date & Name of the Experiment & Page & \null\hfil Remarks\\
   \etocsetnexttocdepth {chapter}
   % variant: \begingroup\hypersetup{hidelinks}\the\toctabletok\endgroup

\protected\def\EXP #1#2{#2 (#1)}


% a standard table of contents (including sections etc..) is still possible:
% \tableofcontents


\chapter{\EXP{6-4-13}{A Sample Experiment}}

\chapter{\EXP{1-4-14}{Another Experiment}}

\chapter{\EXP{6-4-14}{The Final Experiment}}


In response to the edited question using tikz. You can try:

\protected\def\EXP #1#2{#2 (#1)}
\newcommand\ExpChapter [2]{%
 \begin{tikzpicture}[remember picture, overlay]
\node[anchor=center,inner sep=0pt,font=\Large\bfseries] at ($(current page.north west) + (4.7cm,-2.7cm)$) {\thechapter};
\node[anchor=center,inner sep=0pt,font=\Large\bfseries] at ($(current page.north) + (0cm,-2.7cm)$) {#2};
\node[anchor=center,inner sep=0pt,font=\Large\bfseries] at ($(current page.north west) + (18cm,-2.7cm)$) {#1};



\ExpChapter{6-4-13}{A Sample Experiment}

\ExpChapter{1-4-14}{Another Experiment}

\ExpChapter{6-4-14}{The Final Experiment}


But I really wonder why you need \chapter command, with all this extra fancy thing using tikz rather than a fancyhdr for example. It would have been much easier to drop altogether this abuse of \chapter, and design commands as suggested in the initial comments which prepare the table-"toc" via a customly prepared auxiliary file.


The following may be a (hopefully reasonable) first step towards achieving your objective. It uses the tocloft package extensively. It also uses the optional argument of the \chapter command to insert information about the date of the experiment in the ToC entry.

Some of the spacing, font weight, and font size choices may not be to your full liking, but since you didn't provide explicit guidance on these matters I had to make some assumptions. You mentioned in a comment that the "Remarks" column should be left empty; in that case, it's probably better to leave it out entirely (rather than clutter the appearance of the ToC with an empty column), right?

enter image description here

% \renewcommand\chaptername{Experiment}  %% optional
  \renewcommand{\contentsname}{Table of Contents}
  \renewcommand{\cftaftertoctitle}{\hfill \null\\[2ex]
  \normalfont No.\hspace{0.5cm}Date \hspace{2cm}Name of Experiment \hfill Page}

\chapter[2013.06.04\hspace{1cm}Name of first experiment]{Name of first experiment}

\chapter[2013.07.05\hspace{1cm}Name of second experiment]{Name of second experiment}
  • please see my edited question – subham soni Apr 6 '14 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.