I wanted to add the \listoffigures
and \listoftables
to my table of contents. I found this post where a user shared his/her code to add the \listoffigures
. I implemented it and it worked as intendend. I then proceeded to replace "figure" with "table" to hopefully get the same result but for the list of tables. Even though the ToC looked as intended, the actual list of tables at the end of my document was empty. Now I am here writing this post.
This is the code that I copy+pasted to successfully add the listoffigures to my ToC:
\newcommand{\insertfigure}{\begin{figure}\caption{A figure caption}\end{figure}}
\makeatletter
\renewcommand\listoffigures{%
\section{\listfigurename}% Used to be \section*{\listfigurename}
\@mkboth{\MakeUppercase\listfigurename}%
{\MakeUppercase\listfigurename}%
\@starttoc{lof}%
}
The following is my modified code (figure->table) that I had hoped would work for the list of tables, but as outlined above, doesn't:
\newcommand{\inserttable}{\begin{table}\caption{A table caption}\end{table}}
\makeatletter
\renewcommand\listoftables{%
\section{\listtablename}% Used to be \section*{\listfigurename}
\@mkboth{\MakeUppercase\listtablename}%
{\MakeUppercase\listtablename}%
\@starttoc{lof}%
}
This is the result I would like, but the actual list of tables should also appear at the end of my document:
Translation:
- B. Appendix 2
- B.1. List of figures
- B.2. List of tables
Any suggestions?
\@starttoc{lot}
(lot
is forlist of tables
) instead of\@starttoc{lof}
(lof
islist of figures
).\insertfigure
is simply used to make sure there's something to put in the list of figures in the first place. You wouldn't want that in your actual document, so you don't need that command.