Following the answer of David Carlisle on list of figures and tables when there are no figures or tables?
\documentclass[10pt,twocolumn]{article}
\usepackage{lipsum}
\def\wheninteresting#1{%
\setbox0\vbox{#1}%
\ifdim\ht0>35pt
\unvbox0
\fi}
\begin{document}
\tableofcontents
\wheninteresting{
\addcontentsline{toc}{section}{List of Figures}
\listoffigures
}
\wheninteresting{
\addcontentsline{toc}{section}{List of Table}
\listoftables
}
\section{First section}
...
In my document, I had to set the line \ifdim\ht0>35pt to \ifdim\ht0>100pt to make this work. Because I do not know why but my page headers are bigger than just 35pt. More precisely, I added \typeout{The height of the list is '\the\ht0'} before \ifdim\ht0>35pt, and I got The height of the list is '51.49147pt' for an empty list.
The question would be, can the hard coded value of 35pt to be dynamically calculated, so his solution can work with any latex document class and styling?
