1

Can I define the style of table of contents by using table in LaTeX? I want to do book of abstract and start with time table of speakers. What should I do if I do not want to do it manually?

cgnieder
  • 66,645
ake
  • 11

1 Answers1

2

There is an example in section 29. The TOC as a table of the etoc manual. If you use acrobat reader pdf viewer and go to page 53 you will see an icon near top, clicking on it will allow copying the code. Don't engage into that if you don't understand LaTeX macros enough.

Here it is actually (took me a while to realize I could copy paster myself): (you need \usepackage{hyperref} and \usepackage{etoc})

%% LaTeX2e file `etocsnippet-29-A.tex'
%% generated by the `filecontentsdef' environment
%% from source `etoc' on 2016/09/29.
%%
\begingroup
\etocglobaldefs % necessary for \etocname etc... to survive &

% observe the locations of the \\
\etocsetstyle{part}
  {}
  {\\\hline}
  {\strut\etocnumber &\bfseries\etocname&\etocpage }
  {}

\etocsetstyle{section}
  {}
  {\etociffirst{\etocifnumbered{\\\hline}{\\\hline\hline}}{\\}}
  {\etocnumber&\etocname &\etocpage }
  {}

\etocsetstyle{subsection}
  {}
  {\\}
  {&\makebox[1cm][c]{\etocnumber}%
    \parbox[t]{\dimexpr6cm-\tabcolsep\relax}{\sloppy\itshape\etocname\strut}%
   &\itshape\etocpage }
  {}

\etocsettocstyle
    {\hypersetup{hidelinks}%
     \begin{longtable}{|>{\bfseries}c|p{7cm}|r|}
     \hline
     \multicolumn{3}{|c|}{\Large\bfseries\strut\strut TABLE OF CONTENTS}%
     }
    {\\\hline\end{longtable}}

\etocsetnexttocdepth {subsection}

\tableofcontents
\endgroup

There is another simpler example on page 53:

%% LaTeX2e file `etocsnippet-29-B.tex'
%% generated by the `filecontentsdef' environment
%% from source `etoc' on 2016/09/29.
%%
\begin{center}
\etocsetstyle{section}
             {}
             {\etociffirst{\\\hline\hline}{\\\hline}}
             {\etocname & \etocnumber & \etocpage }
             {}

\etocsettocstyle
   {\hypersetup{hidelinks}\begin{tabular}{|p{4cm}|c|c|}\hline
    \multicolumn{1}{|c|}{\bfseries Section}&
    \bfseries number&
    \bfseries page}
   {\\\hline\end{tabular}}

\etocglobaldefs % MANDATORY !!
\etocsetnexttocdepth{1}

\tableofcontents % \ref{toc:overview}
\end{center}