# List of tables error while using \usepackage[subfigure]{tocloft}

I have a problem with my document which gives me the following error in Overleaf:

\l@table #1#2->\ifnum \c@lotdepth
>\z@ \vskip \cftbeforetabskip {\leftskip \...
l.1 ...le}{\numberline {1}{\ignorespaces Test}}{4}
%


I have figures, subfigures which work fine and show up as I want them to be. However, I now wanted to insert my first table and I get this error and it does not show up in my list of tables. I read up and could identify that it has to with my subfigure package. How can I solve the problem without changing the package as I need it for my other figures?

My MWE:

\documentclass[11pt]{article}
\usepackage{blindtext,tabularx,graphicx}

\usepackage[margin=1in]{geometry}
\usepackage[list=true]{subcaption}
\usepackage[labelfont=bf,labelsep=period]{caption}

% Formatting ToC
\usepackage[subfigure]{tocloft}
\setcounter{tocdepth}{3}

%% Adjust spacing between number and title in ToC

%% Adjust dots in ToC & LoF
\renewcommand\cftdotsep{1}
\makeatletter
\renewcommand{\@dotsep}{1}
\makeatother

% Formatting LoF
\renewcommand{\listfigurename}{\section*{LIST OF FIGURES}}
\newcounter{lofdepth}
\setcounter{lofdepth}{3}
\cftpagenumbersoff{subfigure}

% Formatting LoT
\renewcommand{\listtablename}{\section*{LIST OF TABLES}}
\setcounter{tocdepth}{3}
\renewcommand{\listtablename}{\section*{LIST OF TABLES}}

\begin{document}

\tableofcontents
\clearpage
\listoffigures
\clearpage
\listoftables
\clearpage

\section{Nice0}
\begin{figure}[htb]
\centering
\includegraphics[width=\textwidth]{example-image}
\captionsetup[subfigure]{skip=8pt,position=bottom}
\parbox{0.5\textwidth}{\subcaption[Test]{\bf Test}}\hfill
\parbox{0.5\textwidth}{\subcaption[Test2]{\bf Test2}}
\caption[SuperTest]{{\bf Test} \\Histogram of (a) Test and (b) most common Test sample.} \label{figure:Test}
\end{figure}

\clearpage
\section{Nice1}

\begin{table}[htbp]
\caption[Test]{\bf Test} \blindtext
\begin{center}
\begin{tabular}{|l||c|c|} \hline\hline
Ice Cream Store & Location & How to Get There \\ \hline
Toscanini’s & Central Square & Just walk! \\
Herrell’s & Harvard Square & Red Line \\
J.P. Licks & Davis Square & Red Line \\
Ben \& Jerry’s & Newbury Street & Green Line \\ \hline\hline
\end{tabular}
\end{center}
\end{table}
\label{table:Test}

\end{document}

• Unrelated to the issue, but \label{table:Test} should better be placed inside of the corresponding table environment. Also, do not use \bf to make your captions bold. \bf is deprecated and if you want all your captions to be bold, add font=bf to the options of the caption package instead. Apr 25 '20 at 15:27

The following seems to work for me but don't ask me why.

% subtocprob.tex  SE 540609

\documentclass[11pt]{article}
\usepackage{blindtext,tabularx,graphicx}

\usepackage[margin=1in]{geometry}
\usepackage[list=true]{subcaption}
\usepackage[labelfont=bf,labelsep=period]{caption}

% Formatting ToC
%\usepackage{subfigure}
\usepackage%[subfigure]
{tocloft}
%\usepackage{subfigure}
\setcounter{tocdepth}{3}

%% Adjust spacing between number and title in ToC

%% Adjust dots in ToC & LoF
\renewcommand\cftdotsep{1}
\makeatletter
\renewcommand{\@dotsep}{1}
\makeatother

% Formatting LoF
\renewcommand{\listfigurename}{\section*{LIST OF FIGURES}}
%\newcounter{lofdepth}
\setcounter{lofdepth}{3}
\cftpagenumbersoff{subfigure}

% Formatting LoT
\renewcommand{\listtablename}{\section*{LIST OF TABLES}}
\setcounter{tocdepth}{3}
\renewcommand{\listtablename}{\section*{LIST OF TABLES}}

\begin{document}

\tableofcontents
\clearpage
\listoffigures
\clearpage
\listoftables
\clearpage

\section{Nice0}
\begin{figure}[htb]
\centering
\includegraphics[width=\textwidth]{example-image}
\captionsetup[subfigure]{skip=8pt,position=bottom}
\parbox{0.5\textwidth}{\subcaption[Test]{\bf Test}}\hfill
\parbox{0.5\textwidth}{\subcaption[Test2]{\bf Test2}}
\caption[SuperTest]{{\bf Test} \\Histogram of (a) Test and (b) most common Test sample.} \label{figure:Test}
\end{figure}

\clearpage
\section{Nice1}

\begin{table}[htbp]
\caption[Test]{\bf Test} \blindtext
\begin{center}
\begin{tabular}{|l||c|c|} \hline\hline
Ice Cream Store & Location & How to Get There \\ \hline
Toscanini’s & Central Square & Just walk! \\
Herrell’s & Harvard Square & Red Line \\
J.P. Licks & Davis Square & Red Line \\
Ben \& Jerry’s & Newbury Street & Green Line \\ \hline\hline
\end{tabular}
\end{center}
\end{table}
\label{table:Test}

\end{document}


I deleted any reference to subfigure and also commented out the \newcounter{lofdepth} line.

• My code is in general probably not very clean. Your suggestion fixes the problem on my side as well! Thank you @Peter Wilson
– PSA
Apr 25 '20 at 18:17