I would like to have LaTeX compilation (I use pdflatex) give an error if there exists one label in my document that I do not reference. Is this possible? This is to ensure that I mention every table and figure for which I set a label. I would prefer to use the same label and ref commands as always, if possible.

1 Answer 1


You could use the package refcheck. There already a question you might want to check out: here. It worked for me in LuaLaTeX.

I'll give a brief example:


    % ...
    \caption{A nice picture of my dog}\label{fig:dog}
  % As seen in figure~\ref{fig:dog}

With the second last line commented out a call of your LaTeX compiler (in my case LuaLaTex) will produce output like this


Package refcheck Warning: Unused label `fig:dog' on input line 8.


The output contains a warning that tells you that a label was never referenced. If you remove the % infront of the second line, the label will be referenced and therefore the warning disappears.

  • Welcome to TeX.SX! Can you elaborate on your answer" At the moment it's more like a comment
    – user31729
    Commented Jul 4, 2015 at 14:15
  • How can I turn the warning into an error though?
    – Xu Wang
    Commented Jul 4, 2015 at 15:27
  • Refcheck has a command refcheckxrdoc (doc) to manually invoke the check (I have never used it). If the check fails you could probably throw an error by yourself (I have not done this as well) but here is a question regarding this topic. I would write a bash script to extract such warnings from the log file. Commented Jul 4, 2015 at 23:13
  • @FabianKöhler Thanks, I posted a follow-up question here: tex.stackexchange.com/questions/253773/…
    – Xu Wang
    Commented Jul 5, 2015 at 11:59
  • @FabianKöhler also, please use the @. I was not notified of your message. I had to check manually.
    – Xu Wang
    Commented Jul 5, 2015 at 11:59

You must log in to answer this question.

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