# Adjusting the look of ToC

The things I was able to achieve till now:

i) Modifying the title of ToC

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:

\documentclass[12pt,oneside]{book}
\usepackage{libertine}
\usepackage{background}
\usepackage{lipsum}
\usetikzlibrary{calc}
\backgroundsetup{
angle=0,
scale=1,
opacity=1,
color=black,
contents={%
\begin{tikzpicture}[remember picture, overlay]
\node[anchor=center,inner sep=0pt] at ($(current page.north west) + (17.3cm,-1.5cm)$) {\thepage};
\end{tikzpicture}%
}
}

\begin{document}
\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};
\end{tikzpicture}%
\lipsum[4-10]
\end{document}


How do I do that?

Here is my MWE:

\documentclass[12pt,oneside]{book}

\begin{document}
\begin{titlepage}
\setcounter{tocdepth}{0}
\tableofcontents
\end{titlepage}
\chapter{Hello World}
....
\chapter{Hi}
.....
\end{document}


And this is its output:

![enter image description here][2]


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

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. –  jfbu 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? –  jfbu Apr 6 '14 at 7:13

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

\chapter{\EXP{date}{name}}


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).

\documentclass [a4paper]{book}
\usepackage{etoc}
\usepackage{hyperref}
\usepackage{array}
\usepackage{longtable}

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

\newcommand*\PrepareChapter{%
\edef\TEMP {\etocthename}\toks2 \expandafter{\TEMP}%% expt date and name
\edef\toctablepiece{\noexpand\hline
\noexpand\strut\the\toks0 &
\the\toks2 &
\the\toks4 &\noexpand\\ }%
}

\newcommand\TOCofexperiments{%
\etocsetstyle{chapter}{}{}
{\PrepareChapter \appendtotok\toctabletok\toctablepiece}
{}
%
\etocsettocstyle
{\def\EXP ####1####2{\unexpanded{####1} &
\toctabletok{%
\begin{longtable}{|>{\centering}p{1cm}|c|p{5cm}|c|p{2cm}|}
\multicolumn{5}{c}{\Large\bfseries\rule[-2ex]{0pt}{0pt}%
\hline
Expt. No & Date & Name of the Experiment & Page & \null\hfil Remarks\\
}}
{\global\toctabletok\expandafter{\the\toctabletok
\hline
\end{longtable}}}
%
\etocsetnexttocdepth {chapter}
\tableofcontents
\markboth{\textsc{Contents}}{\textsc{Contents}}
\the\toctabletok
}

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

\begin{document}

% \tableofcontents

\TOCofexperiments

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

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

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

\end{document}


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

\protected\def\EXP #1#2{#2 (#1)}
\newcommand\ExpChapter [2]{%
\chapter{\EXP{#1}{#2}}\thispagestyle{empty}
\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};
\end{tikzpicture}}


and

\begin{document}\pagestyle{empty}
\TOCofexperiments

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

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

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

\end{document}


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?

\documentclass{book}
% \renewcommand\chaptername{Experiment}  %% optional
\usepackage{tocloft}
\renewcommand{\cfttoctitlefont}{\hfill\Large\bfseries}
\renewcommand{\cftaftertoctitle}{\hfill \null\\[2ex]
\normalfont No.\hspace{0.5cm}Date \hspace{2cm}Name of Experiment \hfill Page}
\setlength{\cftaftertoctitleskip}{2ex}
\setlength{\cftchapnumwidth}{3em}

\begin{document}
\tableofcontents
\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}
\end{document}

-
please see my edited question –  subham soni Apr 6 '14 at 8:38