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.


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? – Hendrik Wiese Nov 23 '16 at 12:18
  • See the updated answer. – Pieter van Oostrum Nov 23 '16 at 15:28
  • Please Note: As these solutions hack into the internals, they may someday break if the internals are significantly changed. – Pieter van Oostrum Nov 23 '16 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. – Hendrik Wiese Nov 23 '16 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.