1

For one of our large thesis project we are in need to add a duplicate TOC in tabular format with some square boxes like \Box. I am looking for solution where the output will be something to this:

\documentclass[letterpapter]{report}

\usepackage{multirow}
\usepackage{latexsym}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}

\begin{document}
\tableofcontents

\chapter{Chapter 1}
\section{Section}
\subsection{SubSection}
\subsubsection{SubSubSection}
\paragraph{Paragraph}
\subparagraph{SubParagraph}
\chapter{Chapter 2}
\chapter{Chapter 3}
\chapter{Chapter 4}
\chapter{Chapter 5}
\chapter{Chapter 6}

\appendix
\chapter{Grade Summary}

\begin{tabular}{ |p{2cm}|p{3cm}|p{1cm}|p{1cm}|  }
 \hline
 \multicolumn{2}{|c|}{\textbf{Sumnmary}} &\multicolumn{2}{|c|}{\textbf{Graded}}\\
 \hline
 \multicolumn{2}{|c|}{}&\textbf{YES}&\textbf{NO}\\
 \hline
 1   &\textbf{Chapter 1}&$\Box$& $\Box$ \\
 \hline
 1.1 &\textbf{Section}&$\Box$& $\Box$ \\
 \hline
 1.1.1 &\textbf{SubSection}&$\Box$& $\Box$ \\
 \hline
 1.1.1.1    &SubSubSection&$\Box$& $\Box$ \\
 \hline
 1.1.1.1.1 &Paragraph&$\Box$& $\Box$ \\
 \hline
 1.1.1.1.1.1&SubParagraph&$\Box$& $\Box$ \\
 \hline
 2 &\textbf{Chapter 2}&$\Box$& $\Box$ \\
 \hline
\end{tabular}
\end{document}

I was looking into etoc but it looks like it will change both the TOC format so not sure if that would be an option to look into.

Any help is appreciated and thanks in advance for looking into it.

1
  • To address the comment at end of your post and as addition to my answer etoc will not change the main TOC format if used with document classes it knows about.
    – user691586
    Oct 12, 2023 at 12:17

1 Answer 1

0

Here is how to achieve with etoc.

Two delicate points:

  1. how to handle the \\\hline, I followed the etoc manual
  2. how to avoid including in tabular TOC the last chapter, I employed an etoc manual "depth tag" stuff.
\documentclass[letterpapter]{report}

\usepackage{multirow}
\usepackage{latexsym}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}

\usepackage{etoc}
% we will use an etoc device of depth tags
% in order to not include in tabular TOC
% the appendix stuff,
% let's tell etoc to ignore the depth tags
% for time being, we will activate later
\etocignoredepthtags
\begin{document}
\tableofcontents

\chapter{Chapter 1}
\section{Section}
\subsection{SubSection}
\subsubsection{SubSubSection}
\paragraph{Paragraph}
\subparagraph{SubParagraph}
\chapter{Chapter 2}
\chapter{Chapter 3}
\chapter{Chapter 4}
\chapter{Chapter 5}
\chapter{Chapter 6}

\appendix
% let's instruct etoc to not include subsequent
% stuff in the tabular TOC
\etocdepthtag.toc{ignoredbytabular}
\chapter{Grade Summary}

\begingroup
% make definitions influencing etoc rendering but limit
% them to a group
\etocsettocstyle{%
\begin{tabular}{ |p{2cm}|p{3cm}|p{1cm}|p{1cm}|  }
 \hline
 \multicolumn{2}{|c|}{\textbf{Sumnmary}} &\multicolumn{2}{|c|}{\textbf{Graded}}\\
 \hline
 \multicolumn{2}{|c|}{}&\textbf{YES}&\textbf{NO}%
 }
 {\\\hline\end{tabular}}
\etocsetstyle{chapter}
  {}
  {\\\hline}
  {\etocnumber &\textbf{\etocname}& $\Box$& $\Box$}
  {}
\etocsetstyle{section}
  {}
  {\\\hline}
  {\etocnumber &\textbf{\etocname}& $\Box$& $\Box$}
  {}
\etocsetstyle{subsection}
  {}
  {\\\hline}
  {\etocnumber &\textbf{\etocname}& $\Box$& $\Box$}
  {}
\etocsetstyle{subsubsection}
  {}
  {\\\hline}
  {\etocnumber &\etocname& $\Box$& $\Box$}
  {}
\etocsetstyle{paragraph}
  {}
  {\\\hline}
  {\etocnumber &\etocname& $\Box$& $\Box$}
  {}
\etocsetstyle{subparagraph}
  {}
  {\\\hline}
  {\etocnumber &\etocname& $\Box$& $\Box$}
  {}
\etocglobaldefs % needed for \etocnumber, \etocname to work in tabular
% tell etoc to obey depth tags, and set the one attached
\etocobeydepthtags
% to chapters the tabular must ignore to be achieve the effect
\etocsettagdepth{ignoredbytabular}{none}
\tableofcontents
\endgroup

\end{document}

Output: tabular TOC with etoc

2
  • This example might need in real life to use a longtable in place of a tabular, which a priori only means making in provided code the obvious adjustments.
    – user691586
    Oct 12, 2023 at 12:19
  • It works like a charm. :)
    – MoinR
    Oct 28, 2023 at 15:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .