I'm surprised that I cannot find such a command, as it seems like basic functionality. I'm trying to create one, and am going down the route of comparing \pageref{thelabel} and \thepage, but this obviously isn't guaranteed to work when the label and the reference are on the same page.
Any ideas? Either a pointer to an existing command, or a way to write a new one?
Many thanks,
Andrew
Minimal (sort of) Working Example:
Code: Select all
\documentclass{article}
\usepackage{ifthen}
\newcommand{\locref}[1]{\ifthenelse{\pageref{#1}<\thepage}{above}{below}}
\begin{document}
% Here the command should resolve to "below" and does
Compared to this paragraph, the label is \locref{thelabel}.
\clearpage
% Here the command should resolve to "below" and does
Compared to this paragraph, the label is \locref{thelabel}.
This paragraph is above the label.
This paragraph contains the label.\label{thelabel}
This paragraph is below the label.
% Here the command should resolve to "above" but doesn't
Compared to this paragraph, the label is \locref{thelabel}.
\clearpage
% Here the command should resolve to "above" and does
Compared to this paragraph, the label is \locref{thelabel}.
\end{document}