Thanks Wolfgang. I am experimenting with your code and there has arisen a problem. The book I am typesetting has some pages before the text on page-1 starts (cover and so on). Therefore the code \def\mypageref[#1]{\setpagestate[hvdm][#1]\color[red]{page=\pagenumber\ and pageref=\pagestaterealpage{hvdm}{#1}}} produces "page=29 and pageref=31". Not as intended. Do I change the macro \pagestaterealpage into what macro? I tried \pagestatepage, but that wasn't the right idea. Now what further to change? Hans van der Meer On 17 Jan 2016, at 19:37, Wolfgang Schuster > wrote: \definepagestate[hans] \starttext One\setpagestate[hans][one] \page[+2] Two\setpagestate[hans][two] Three\setpagestate[hans][three] \blank \ifnum0\pagestaterealpage{hans}{two}=0\pagestaterealpage{hans}{one} The references are on the same page. \else The references are on different pages. \fi \blank \ifnum0\pagestaterealpage{hans}{two}=0\pagestaterealpage{hans}{three} The references are on the same page. \else The references are on different pages. \fi \stoptext