I used \autoref throughout my thesis and when doing corrections and needing to keep track of them using the todonotes package, I noticed that the \autoref function generates wrong labels.
To show what I mean, here's MWE:
\documentclass{article}
\usepackage{hyperref}
\usepackage{todonotes}
\begin{document}
\section{ABC}
\section{DEF}
\section{EFG}
\section{HIJ}
\begin{figure}
\centering
XXX
\caption{Three Xs}
\label{fig:XXX}
\end{figure}
\begin{figure}
\centering
YYY
\caption{Three Y's \todo[inline]{remove the apostrophe}}
\label{fig:YYY}
\end{figure}
Should be Figure 1: \autoref{fig:XXX}
Should be Figure 2: \autoref{fig:YYY}
\end{document}
This is what it generates:
I read around and it seems that it may be doing that because as soon as you insert any todonotes in the caption, it thinks that it's the main body and then the following label then refers to the section (but somehow keeps the figure's counter). This is clearly wrong.
Putting label before \caption doesn't work. Putting all todonotes after \caption is not suitable as the corrections are WITHIN caption.
Could anybody suggest a solution, please?
Many thanks, Nickolai.