When writing documents, I consider it to be necessary that all figures and tables are referenced (\ref
) in the text, whether or not I've remembered to \label
them. LaTeX does not currently warn if a figure or table is not referenced. Is there a way to ensure that this is flagged up as a warning?
Note that I am specifically concerned about figures and tables, not chapter or section headings; it will be no good looking just at \label
s that don't have an associated \ref
.
In other words, it should report boo
and not report bla
in the following MWE:
\documentclass{article}
\begin{document}
\section{BLA}\label{bla}
\section{BOO}\label{boo}
In Section~\ref{bla} we do something.
\end{document}
Best Answer
Use the package refcheck. It is
Note that it checks for labels that are not used in the text but not for tables and figures that are not labelled. Thus if you got a table or figure without a label you'll not get warned. If you compile the following you'll get a demonstration of its core features (the idea for this is from the package's excellent demo):
The last two equations will be marked by "?" in the output because they're not labelled and referred to. The table and figure will be marked by "?" because they're labelled but not referred to. Also the .log file will contain:
Note that refcheck should be loaded after the ams packages and the hyperref package.
Relatedly you may also want to check for duplicate labels.