I have the following question about references. Using for example \at one can say somehting like "see on \at{page}[ref] for the figure.. But when the figure is one the same page it seems a bit superfluous to reference to it. In the same manner it is a bit of an overkill to put a hyperlink to the page where this link resides itself. It is clear that ConTeXt knows if it is on the same page as is referenced, because then a link is coloured with contrastcolor instead of color. Now the question: how easy/difficult is it to either suppress such an \at-reference or switch between chosen alternate texts for links on or off the same page as the referenced item? Hans van der Meer
Am 20.11.2011 um 18:46 schrieb Hans van der Meer:
I have the following question about references.
Using for example \at one can say somehting like "see on \at{page}[ref] for the figure.. But when the figure is one the same page it seems a bit superfluous to reference to it. In the same manner it is a bit of an overkill to put a hyperlink to the page where this link resides itself.
It is clear that ConTeXt knows if it is on the same page as is referenced, because then a link is coloured with contrastcolor instead of color.
Now the question: how easy/difficult is it to either suppress such an \at-reference or switch between chosen alternate texts for links on or off the same page as the referenced item?
\def\SamePage[#1]% {\doifreferencefoundelse{#1} {\ifnum\referencepagestate=1 \unknown % reference is on the same page \else \at[#1]% \fi} {\donothing}} \starttext \pagereference[one] \pagereference[two] One: \SamePage[one] \page Two: \SamePage[one] \stoptext Wolfgang
Thanks Wolfgang for the code. Just in case it is of use I concocted my variation on this theme. Now this simply replaces the \in, \at and \about macro's with one that does not show on the page where the link originates, but behaves as of old everywhere else. I introduced the unskip in order to remove the space that ruins the end of a line when there is nothing to display. For example from \in{see there}[ref]. <--this period would otherwise acquire a space before it. \def\SamePageDo#1[#2]% {\doifreferencefoundelse{#2} {\ifnum\referencepagestate=1 \unskip%\unknown % reference is on the same page \else #1[#2]% \fi} {\unskip}} % reference not found \let\oldin=\in \let\oldat=\at \let\oldabout=\about \def\in{\SamePageDo\oldin} \def\at{\SamePageDo\oldat} \def\about{\SamePageDo\oldabout} Hans van der Meer On 20 nov. 2011, at 19:42, Wolfgang Schuster wrote:
Am 20.11.2011 um 18:46 schrieb Hans van der Meer:
I have the following question about references.
Using for example \at one can say somehting like "see on \at{page}[ref] for the figure.. But when the figure is one the same page it seems a bit superfluous to reference to it. In the same manner it is a bit of an overkill to put a hyperlink to the page where this link resides itself.
It is clear that ConTeXt knows if it is on the same page as is referenced, because then a link is coloured with contrastcolor instead of color.
Now the question: how easy/difficult is it to either suppress such an \at-reference or switch between chosen alternate texts for links on or off the same page as the referenced item?
\def\SamePage[#1]% {\doifreferencefoundelse{#1} {\ifnum\referencepagestate=1 \unknown % reference is on the same page \else \at[#1]% \fi} {\donothing}}
\starttext
\pagereference[one] \pagereference[two]
One: \SamePage[one]
\page
Two: \SamePage[one]
\stoptext
Wolfgang
Am 20.11.2011 um 21:26 schrieb Meer, H. van der:
Thanks Wolfgang for the code.
Just in case it is of use I concocted my variation on this theme. Now this simply replaces the \in, \at and \about macro's with one that does not show on the page where the link originates, but behaves as of old everywhere else. I introduced the unskip in order to remove the space that ruins the end of a line when there is nothing to display. For example from \in{see there}[ref]. <--this period would otherwise acquire a space before it.
Instead of \unskip you should use \removeunwantedspaces which does a check before it calls \unskip.
\def\SamePageDo#1[#2]% {\doifreferencefoundelse{#2} {\ifnum\referencepagestate=1 \unskip%\unknown % reference is on the same page \else #1[#2]% \fi} {\unskip}} % reference not found \let\oldin=\in \let\oldat=\at \let\oldabout=\about \def\in{\SamePageDo\oldin} \def\at{\SamePageDo\oldat} \def\about{\SamePageDo\oldabout}
Don’t redefine \in, at and \about because all three commands can also be used in math mode where they have a different meaning but with your redefinition they can’t be used anymore for math. Wolfgang
participants (3)
-
Hans van der Meer
-
Meer, H. van der
-
Wolfgang Schuster