TransWikia.com

Include List of Tables directly in each section/subsection etc. in Table of Contents

TeX - LaTeX Asked on August 25, 2021

I’d like to include my list of tables directly in the ToC. This means tables of every section, subsection etc. are listed in the ToC and not in the list of tables separately.

This example below does not result in what I want. Table 1 should follow directly under subtitle1, Table 2 under subtitle2, and Table 3 just below title2

How do I have to modify his example?

documentclass[11pt,a4paper]{article}
usepackage{graphicx}

begin{document}

tableofcontents 
listoftables

newpage
section{title1}
subsection{subtitle1}

begin{table}[htp!]
caption{Table 1}
label{tab:my-table}
begin{tabular}{ll}
1 & 2 
neo & old 
end{tabular}
end{table}

subsection{subtitle2}

begin{table}[htp!]
caption{Table 2}
label{tab:my-table}
begin{tabular}{ll}
1 & 2 
neo & old
end{tabular}
end{table}

section{title2}

begin{table}[htp!]
caption{Table 3}
label{tab:my-table}
begin{tabular}{ll}
1 & 2 
neo & old
end{tabular}
end{table}

end{document}

enter image description here

One Answer

Try this:

% tablesintocprob.tex SE 554629

documentclass[11pt,a4paper]{article}
usepackage{graphicx}

begin{document}

tableofcontents 
%listoftables

newpage
section{title1}
subsection{subtitle1}

begin{table}[htp!]
caption{Table 1}
addcontentsline{toc}{table}{Table 1}
label{tab:my-table}
begin{tabular}{ll}
1 & 2 
neo & old 
end{tabular}
end{table}

subsection{subtitle2}

begin{table}[htp!]
caption{Table 2}
addcontentsline{toc}{table}{Table 2}
label{tab:my-other-table}
begin{tabular}{ll}
1 & 2 
neo & old
end{tabular}
end{table}

section{title2}

begin{table}[htp!]
caption{Table 3}
addcontentsline{toc}{table}{Table 3}
label{tab:my-another-table}
begin{tabular}{ll}
1 & 2 
neo & old
end{tabular}
end{table}

end{document}

I'm not sure that it gives the result you are after but it will give you a start.

Correct answer by Peter Wilson on August 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP