1

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

3

Patch the \@setref macro.

\documentclass{article}
\usepackage{todonotes}
\usepackage{etoolbox}
\makeatletter
    \patchcmd{\@setref}{\ifx#1\relax}{\ifx#1\relax \todo{MISSING REFERENCE}}{}{}
\makeatother
\begin{document}
This is a missing reference: \ref{somefig}.
\end{document}

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

Update:

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

\ifdefined\HyRef@autosetref \patchcmd{\HyRef@autosetref}
      {\else}{\else\todo{MISSING REFERENCE}}{}{}\fi
4
  • Thanks... umh, you don't know by chance how to do this with \autoref from the hyperref package, do you? Commented Nov 23, 2016 at 12:18
  • See the updated answer. Commented 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. Commented 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. Commented 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 .