So currently, the only way to integrate tables and figure in table of contents is to have them setup after the \tableofcontents using \listoffigures and \listoftables. My professor asked for a report to have those indented in the table of contents.

Basically, I need to achieve this: but I only seem to be able to achieve this:

Here is a copy of my code for this file:

\documentclass[11pt, A4]{article}

\usepackage{graphicx}
\usepackage{booktabs}

\begin{document}

\tableofcontents
\listoftables
\listoffigures
\newpage

\section{First Section}
\begin{figure}[!h]
\includegraphics[height=3cm]{image}
\caption{This is an image}
\label{img}
\end{figure}

\section{Second Section}
\begin{table}[!h]
\caption{Just a table}
\label{tabl}
\begin{center}
\begin{tabular}{l|l|c}
\toprule
& title &   \\
\toprule
a & b     & c \\
\hline
d & e     & f \\
\hline
g & h     & i
\end{tabular}
\end{center}
\end{table}

\end{document}


Here is what the rest of the document looks like:

Here is a suggestion using tocbasic for the format of the figure and table entries (and for the entry of the TOC in the TOC):

\documentclass[11pt, a4]{article}

\makeatletter
\renewcommand*{\ext@figure}{toc}
\renewcommand*{\ext@table}{toc}
\makeatother

\usepackage{tocbasic}
\renewcommand*\tableofcontents{\listoftoc[{\contentsname}]{toc}}
\setuptoc{toc}{totoc}% TOC entry in TOC

\newcommand\entrywithprefix[2]{\hfill#1~#2 - }
\DeclareTOCStyleEntry[
numwidth=6em,
entrynumberformat=\entrywithprefix{\figurename}
]{tocline}{figure}
\DeclareTOCStyleEntry[
numwidth=6em,
entrynumberformat=\entrywithprefix{\tablename}
]{tocline}{table}

\usepackage{graphicx}
\usepackage{booktabs}

\begin{document}
\tableofcontents

\clearpage
\section{First Section}
\begin{figure}[htbp]
\includegraphics[height=3cm]{example-image-a}
\caption{This is an image}
\label{img1}
\end{figure}
\begin{figure}[htbp]
\includegraphics[height=3cm]{example-image-b}
\caption{This is another image}
\label{img2}
\end{figure}
\begin{table}[htbp]
\caption{Just a table in first section}
\label{tabl}
\begin{center}
\begin{tabular}{l|l|c}
\toprule
& title &   \\
\toprule
a & b     & c \\
\hline
d & e     & f \\
\hline
g & h     & i
\end{tabular}
\end{center}
\end{table}

\section{Second Section}
\begin{table}[htbp]
\caption{Just a table in second section}
\label{tabl2}
\begin{center}
\begin{tabular}{l|l|c}
\toprule
& title &   \\
\toprule
a & b     & c \\
\hline
d & e     & f \\
\hline
g & h     & i
\end{tabular}
\end{center}
\end{table}

\begin{figure}[htbp]
\includegraphics[height=3cm]{example-image-a}
\caption{This is an image in second section}
\label{img3}
\end{figure}
\end{document}


Result:

• Right now though, tables are labelled as figures and figures as tables... They just need to be switched right after {tocline}. – Benjamin Chausse Oct 24 '18 at 1:16
• Oops. I have corrected that now. – esdd Oct 24 '18 at 6:34
\documentclass[11pt, a4paper]article}

\usepackage{graphicx}
\usepackage{booktabs}

\makeatletter
\def\ext@figure {toc}
\def\ext@table {toc}
\makeatother

\begin{document}

\tableofcontents
%\listoftables
%\listoffigures
\newpage

\section{First Section}
\begin{figure}[htbp]
\includegraphics[height=3cm]{example-image-a}
\caption{This is an image}
\label{img1}
\end{figure}
\begin{figure}[htbp]
\includegraphics[height=3cm]{example-image-b}
\caption{This is another image}
\label{img2}
\end{figure}
\begin{table}[htbp]
\caption{Just a table in first section}
\label{tabl}
\begin{center}
\begin{tabular}{l|l|c}
\toprule
& title &   \\
\toprule
a & b     & c \\
\hline
d & e     & f \\
\hline
g & h     & i
\end{tabular}
\end{center}
\end{table}

\section{Second Section}
\begin{table}[htbp]
\caption{Just a table in second section}
\label{tabl2}
\begin{center}
\begin{tabular}{l|l|c}
\toprule
& title &   \\
\toprule
a & b     & c \\
\hline
d & e     & f \\
\hline
g & h     & i
\end{tabular}
\end{center}
\end{table}

\begin{figure}[htbp]
\includegraphics[height=3cm]{example-image-a}
\caption{This is an image in second section}
\label{img3}
\end{figure}

\end{document}


### update

To obtain this:

use this in preamble:

\makeatletter
\def\ext@figure{toc}
\def\ext@table {toc}

\let\originalnumberline\numberline

\def\l@figure{\def\numberline##1{\makebox[2cm][l]{Figure\hrulefill##1: }%
\global\let\numberline\originalnumberline}%
\l@subsection}

\def\l@table{\def\numberline##1{\makebox[2cm][l]{Table\hrulefill##1: }%
\global\let\numberline\originalnumberline}%
\l@subsection}
\makeatother