Here's a MWE of my problem. Using the following document
\documentclass{report}
\AtBeginDocument{\listoffigures}
\usepackage{cleveref}
\begin{document}
\begin{figure}
\caption{This caption cross-references \cref{eqn}.}
\label{fig}
\end{figure}
\begin{equation} F = ma \label{eqn}\end{equation}
\end{document}
results in a document that looks like this:
However, if I remove the \listoffigures command from \AtBeginDocument and instead directly call it in the tex file (right after \begin{document}), I get this:
Evidently, in the first case cleveref can't figure out the type of reference, while in the second case it can. What is the difference between these two?
My real use case is a large LaTeX document class file that provides various customizations to the report class, one of which is to create the list of figures automatically, i.e, without the user needing to remember to insert the instruction \listoffigures. How can I get the correct information embedded in the document for cleveref to parse when using the first approach?


AtBeginDocumentout of a class file entirely :) – Vyas Oct 03 '20 at 10:59