So, I have the file backmatter.tex


\addcontentsline{toc}{section}{Перелік ілюстрацій}

\addcontentsline{toc}{section}{Перелік таблиць}


This file is included at very end of main document (right before \end{document}). If I use no tables in my document, it produces the title for list of tables but no table entries obviously. So I could just remove this fragment of code but doing it everytime as I do not use something would be... ...not convenient.

So, for example, how to prevent

\addcontentsline{toc}{section}{Перелік таблиць}

from typesetting if there are no tables in my document?

2 Answers 2


You can use tocbibind to avoid problems in the page number. I also define conditionals for deciding whether a table or a figure was indeed present in the document; such code must go in the preamble.

Using the value of the counters is not safe, because the counters might be tied to chapter and if there's no figure or table in the last chapter, the value is useless.

For the index, I suggest imakeidx that takes care of the inclusion in the table of contents. Using Xindy and not Makeindex is necessary for Cyrillic based documents.



\makeindex[intoc,options=-L ukrainian -C utf8]

% conditional printing of lists













I typeset the document four times, suitably commenting or uncommenting the lines for figure and table.

No figures, no tables

enter image description here

Figures, no tables

enter image description here

No figures, tables

enter image description here

Figures, tables

enter image description here

  • Oh, that works exactly as I planned it to be, thank You! Jan 10, 2023 at 14:19

See package tocbibind:

"The tocbibind package can be used to add document elements like a bibliography or an index to the Table of Contents."

  • 1
    Hmm. I have read documentation, can't get the point how to use it, sorry... (I'm pretty new to LaTex) Jan 10, 2023 at 14:06

You must log in to answer this question.

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