0

Problem: I am trying to put a table of contents into a table so that an agenda tick list can be automatically generated from sections/subsections titles that have been defined in another file. Redefining\cftsecafterpnum and \cftsubsecafterpnum to include horizontal lines is starting the line at the section/subsection indent and not the left border of the table.

What I have tried: I tried setting \setlength\cftsecindent{(value)} and \setlength\cftsubsecindent{(value)} to negative values so as to bring the horizontal line over to the left border of the table but naturally it moved the section/subsection headings to the left too. Using \renewcommand{\cftsecafterpnum} with \hrule threw an error and \hrulefill produced lines only underneath the entries indent and not spanning the table like this:

enter image description here

MWE:

\documentclass{article}

\usepackage[a4paper,inner=2.3cm,outer=2.3cm,top=3cm,bottom=3cm]{geometry}
\usepackage{tocloft}

\setlength\cftbeforetoctitleskip{-16pt}
\renewcommand{\contentsname}{}

\renewcommand{\cftsecafterpnum}{%
    \vskip0.2cm \line(1,0){15cm}
}
\renewcommand{\cftsubsecafterpnum}{%
    \vskip0.2cm \line(1,0){14cm}
}

\begin{document}

\section{Section}
\subsection{Subsection}
\section{Section}
\subsection{Subsection}
\newpage

\def\arraystretch{2}

\begin{tabular}{ |p{6.8cm}|p{1.8cm}|p{1.5cm}|p{1.1cm}|p{2.2cm}|  }

\multicolumn{5}{c}{\Large\bfseries Title} \\
\hline
\hfil\textbf{Section}\hfil & \textbf{Decisions?} & \textbf{Actions?} & \textbf{Dates?}  & \textbf{Completed?}\\
\hline
\tableofcontents & & & &\\

\end{tabular}
\end{document}

It currently looks like this:

Current table look

The formatting of the entries doesn't look good as I stripped out all the formatting commands for the MWE so please ignore the entries aesthetics. I would like for there to be horizontal lines that span the entire table from left to right border after TOC entries and for the extra space underneath 2.1 Subsection to be removed. I couldn't find an option in tocloft for removing space after the TOC if it is even a tocloft setting, I am not sure what is causing that space underneath 2.1 Subsection.

1 Answer 1

1

Not perfect whatsoever and I still have much to learn, but the answer was to just remove the section/subsection numbers and modify the \cftsetindents values.

The last space was caused by the &'s after \tableofcontents & & & &\\.

Working code:

\documentclass{article}

\usepackage[a4paper,inner=2.3cm,outer=2.3cm,top=3cm,bottom=3cm]{geometry}
\usepackage{tocloft}

\setlength\cftbeforetoctitleskip{-16pt}
\renewcommand{\contentsname}{}

\def\numberline#1{}             % Gets rid of page numbers in TOC entries
\cftsetindents{section}{0em}{-0.58em}
\cftsetindents{subsection}{0em}{-0.58em}

\renewcommand{\cftsecafterpnum}{%
    \vskip0.2cm \line(1,0){15.5cm}
}
\renewcommand{\cftsubsecafterpnum}{%
    \vskip0.2cm \line(1,0){15.5cm}
}

\begin{document}

\section{Section}
\subsection{Subsection}
\section{Section}
\subsection{Subsection}
\newpage

\def\arraystretch{2}

\begin{tabular}{ |p{6.8cm}|p{1.8cm}|p{1.5cm}|p{1.1cm}|p{2.2cm}|  }

\multicolumn{5}{c}{\Large\bfseries Title} \\
\hline
\hfil\textbf{Section}\hfil & \textbf{Decisions?} & \textbf{Actions?} & \textbf{Dates?}  & \textbf{Completed?}\\
\hline
\tableofcontents
Meeting Complete & & & & \\
\hline

\end{tabular}
\end{document}

How it looks:

enter image description here

Need to manually change dimensions to line table up if changing page sizes etc but it works for now.

1
  • I have accepted my own answer as it was bugging me on my profile and to stop @community bumping it again so my apologies for it appearing once more.
    – user245306
    Aug 24, 2021 at 19:37

You must log in to answer this question.