I need to write a script in elisp that warns me when a float appears before the page where that float is first referred.
From the .aux file I can extract the label, the number, and the page number of the float. But I need to get the exact page in where each \ref command is placed.
I tried:
\AtBeginDocument{\hypersetup{pageanchor=false}
\let\oldref\ref
\renewcommand{\ref}[1]{{\oldref{#1}\typeout{RefsPagesInLog --> {#1} \thepage}}}
so e.g., \ref{fig:2} in the .tex files prints:
RefsPagesInLog --> {fig:2} 29
in the log file. It almost works but sometimes fails. In very few cases it prints a wrong page number in the log file so my script fails.
Is there a trick to achieve the same goal?
The data I need are the label \ref refers to, and the "exact" page where the refs appear.
\thepageis not completely reliable in the document main text, see e.g. https://tex.stackexchange.com/q/239452/82917 or https://tex.stackexchange.com/q/338084/82917. – campa Apr 21 '17 at 15:35\labelto get the exact page number in the.aux. But I'm not able to imagine how to label a\refcommand. – Gabriele Apr 21 '17 at 15:46\hyperanchorthat could be used (with a\label) to identify the location of a\ref. but each one has to be unique, so you'd still have the problem of identifying the\refs because you'd have to know the label name for each one. – barbara beeton Apr 21 '17 at 15:51