# [Tex/LaTex] List of Tables doesn’t appear

listslongtable

I have a problem with List of Tables. It doesn't appear in my document.

The .cls file is HERE.

Document:

\documentclass[thesis=B,czech]{FITthesis}[2012/06/26]

\usepackage[utf8]{inputenc}

\usepackage{graphicx}
\usepackage{longtable}

\department{text}
\title{text}
\authorGN{text}
\authorFN{text}
\authorWithDegrees{text}
\supervisor{text}
\acknowledgements{text}
\abstractCS{text}
\abstractEN{text}
\placeForDeclarationOfAuthenticity{text}
\declarationOfAuthenticityOption{1}
\keywordsCS{text}
\keywordsEN{text}

\usepackage{chngcntr}
\AtBeginDocument{
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\renewcommand\thefigure{\arabic{figure}}
\renewcommand\thetable{\arabic{table}}
}
\begin{document}

\begin{introduction}
%
\end{introduction}

\chapter {First}

text

\begin{figure}[h]
\caption{Function.}
\label{fig:function}
\end{figure}

\begin{center}
\begin{longtable}{ c | c | c }
$1$ & $2$ & 3 \\ \hline
\caption{tab}
\label{tab:tab}
\end{longtable}
\end{center}

\begin{conclusion}
%
\end{conclusion}

\appendix

\end{document}


The class FITthesis.cls doesn't require an explicit use of \listoftables, since it tries to detect whether the list should be automatically generated or not.

The problem is that the mechanism used to do the automatic detection is not very good, since it's based on the detection of the environment and not on the caption type. If the table environment was used in the document, then the LoT will be produced; otherwise, no list is generated.

This is clearly wrong, since one can have tables with captions not associated with the table environment (one could have longtable, or threeparttable, or \captionof{table}{...}).

For the list of tables, one finds in FITthesis.cls:

\AtEndEnvironment{table}{\gdef\there@is@a@table{}}
\AtEndDocument{\ifdefined\there@is@a@table\label{tab:was:used:in:doc}\fi}
\DeclareRobustCommand{\listoftablescond}{\@ifundefined{r@tab:was:used:in:doc}{}{\listoftables*}}


and this means, as I said before, that the LoT will only be generated if table was used in the document.

Since in the MWE table was not used, the LoT is not produced, even though longtable was present. This is clearly a bad design choice that should be corrected by the author/maintainer of the class. If automatic generation is to be done, then the mechanism must be base on the captions, not on specific environments.

One could explicitly invoke \listoftables in the document, but the, as soon as table is used one will end up having two lists of tables.

The best solution here, while the author/maintainer of the class corrects the issue, is to register also longtable for the automatic generation of the LoT, using:

\makeatletter
\AtEndEnvironment{longtable}{\gdef\there@is@a@table{}}
\makeatother


A complete example:

\documentclass[thesis=B,czech]{FITthesis}[2012/06/26]
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{longtable}

\makeatletter
\AtEndEnvironment{longtable}{\gdef\there@is@a@table{}}
\makeatother

\department{text}
\title{text}
\authorGN{text}
\authorFN{text}
\authorWithDegrees{text}
\supervisor{text}
\acknowledgements{text}
\abstractCS{text}
\abstractEN{text}
\placeForDeclarationOfAuthenticity{text}
\declarationOfAuthenticityOption{1}
\keywordsCS{text}
\keywordsEN{text}

\usepackage{chngcntr}
\AtBeginDocument{
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\renewcommand\thefigure{\arabic{figure}}
\renewcommand\thetable{\arabic{table}}
}
\begin{document}

\begin{longtable}{ c | c | c }
$1$ & $2$ & 3 \\ \hline
\caption{tab}
\label{tab:tab}
\end{longtable}

\end{document}