[NTG-context] Conditional cross references to floats

Wolfgang Schuster schuster.wolfgang at googlemail.com
Mon Jan 17 16:22:03 CET 2011


Am 16.01.2011 um 20:58 schrieb Robert Blackstone:

> Hi all,
> 
> I wonder if it is already possible to perform the following task:
> 
> I have to typeset documents that contain many pictures of various
> sizes. Due to lack of space, some may pictures may not appear on the
> page on which they are discussed. And also in the course of revising
> the document, adding text may push them to another page.  Therefore I
> always refer to every picture with \in and \at. On the other hand,
> changing or deleting text may unexpectedly land them on the correct
> page.
> 
> So sometimes it may happen that the reader, for instance on page 23,
> will be referred to a figure on page 23, which looks rather silly.
> 
> Is there a trick to let ConTeXt automatically omit the reference when
> the picture happens to appear on the correct page (or change the
> reference to « on this page »). In other words, can one make a sort of
> conditional reference that only mentions the page if it is not the
> present page?

ConTeXt has a \atpage and a \somewhere command but none of them
can be used to omit the reference when the float and the reference
are on the same page but it’s not impossible.

As you can see from this example:

\starttext

1. \doifreferencefoundelse{test}{\analyzecurrentreference\ifcase\referencepagestate\relax\or this page\or above\or below\fi}{}

\page

2. \doifreferencefoundelse{test}{\analyzecurrentreference\ifcase\referencepagestate\relax\or this page\or above\or below\fi}{}

\placefigure[force][test]{First}{\framed{One}}

3. \doifreferencefoundelse{test}{\analyzecurrentreference\ifcase\referencepagestate\relax\or this page\or above\or below\fi}{}

\page

4. \doifreferencefoundelse{test}{\analyzecurrentreference\ifcase\referencepagestate\relax\or this page\or above\or below\fi}{}

\stoptext

one can set conditional texts but these are internal macros
(which can change) and meant for users.

Wolfgang



More information about the ntg-context mailing list