I'm looking for a way to add todo notes in addition to the two questionmarks wherever a \ref is undefined/missing.

Currently I'm writing a \todo manually for any \ref that I intend to fulfill later. Figures for example where I don't have the actual image yet. I would like to see this done automatically.

1 Answer 1


Patch the \@setref macro.

    \patchcmd{\@setref}{\ifx#1\relax}{\ifx#1\relax \todo{MISSING REFERENCE}}{}{}
This is a missing reference: \ref{somefig}.

May not work with every package that does something with the ref mechanism.


For \autoref in the hyperref package, add (also between \makeatletter and \makeatother):

\ifdefined\HyRef@autosetref \patchcmd{\HyRef@autosetref}
      {\else}{\else\todo{MISSING REFERENCE}}{}{}\fi
  • Thanks... umh, you don't know by chance how to do this with \autoref from the hyperref package, do you? Nov 23, 2016 at 12:18
  • See the updated answer. Nov 23, 2016 at 15:28
  • Please Note: As these solutions hack into the internals, they may someday break if the internals are significantly changed. Nov 23, 2016 at 15:33
  • I'll keep that in mind, thanks. However since this is a one time solution for my master thesis I suppose (i.e. hope) it will break long after I have handed it in. Nov 23, 2016 at 15:49

You must log in to answer this question.

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