On Thu, Jul 24, 2014 at 1:38 PM, Wolfgang Schuster <schuster.wolfgang@gmail.com> wrote:


I won’t trust this pagenumber check because when a reference appears at the begin of a page
it can sometimes use the pagenumber of the previous page (hard to notice when you use \page
in your examples to force a page break).

ah yes, when the pagetotal is greater  than the pagegoal of the MVL and the pagebox is not splitted the realfolio counter is still the old one. 

\placefigure[none][FOOa]{FOOa}{\externalfigure[cow.pdf][width=1cm]}
\vskip20cm
is shown in \in{figure}[FOOa]%
\doifreferencefoundelse{FOOa}{\ifnum\realfolio=\the\numexpr\currentreferencepage+0\relax\else\at{page}[FOOa]\fi}{}% 




%%% 

\newcount\mypagenr


\def\MyAtPage[#1]%
{\doifreferencefoundelse{#1}{%
%(\the\pagetotal,\the\pagegoal)
\mypagenr=\the\realpageno%
\ifdim\pagegoal<\maxdimen%
\ifdim\pagetotal>\pagegoal\advance\mypagenr by1\fi%
\edef\tmp{\currentreferencepage}%
\ifnum\mypagenr=\the\numexpr\tmp+0\relax\else\at{page}[#1]\fi\fi}{}%
}



\starttext



\placefigure[][FOO]{FOO}{\externalfigure[cow.pdf][width=1cm]}
%\vskip12cm
FOO is shown in \in{figure}[FOO] \MyAtPage[FOO]%

\placefigure[][FOOa]{FOOa}{\externalfigure[cow.pdf][width=1cm]}
\vskip20cm


\placefigure[][FOOb]{FOOb}{\externalfigure[cow.pdf][width=1cm]}
FOOb is shown in \in{figure}[FOOb] \MyAtPage[FOOb]

FOOa is shown in \in{figure}[FOOa] \MyAtPage[FOOa]


FOOc is shown in \in{figure}[FOOc] \MyAtPage[FOOc]
\placefigure[][FOOc]{FOOc}{\externalfigure[cow.pdf][width=1cm]}


FOOd is shown in \in{figure}[FOOd] \MyAtPage[FOOd]
\vskip20cm
\placefigure[][FOOd]{FOOd}{\externalfigure[cow.pdf][width=1cm]}



\stoptext


--
luigi