1

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:

enter image description here

Translation:

  • B. Appendix 2
  • B.1. List of figures
  • B.2. List of tables

Any suggestions?

3
  • You must use \@starttoc{lot} (lot is for list of tables) instead of \@starttoc{lof} (lof is list of figures). Commented Nov 15, 2021 at 14:10
  • Wonderful, it works now. Much thanks!
    – elliot_mmm
    Commented Nov 15, 2021 at 14:19
  • In the answer you link to, \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.
    – Teepeemm
    Commented Nov 15, 2021 at 14:55

1 Answer 1

0

You must use \@starttoc{lot} (lot is list of tables) instead of \@starttoc{lof} (lof is list of figures).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .