[tex-eplain] Treat \refn as a number?

geolsoft at mail.ru geolsoft at mail.ru
Fri Aug 20 14:41:38 CEST 2004


On Fri, Aug 20, 2004 at 12:14:28PM +0200, Rodolfo Medina wrote:
> The \comparemynumberwithrefn command
> will compare a certain value of \mynumber,
> reported by \refn, with the actual one:

and later

> Similarly, the \comparefoliowithrefn command
> will compare a certain page number,
> reported by \refn, with the actual:

and later

> Can this deal with your case?
> If not, could you maybe send your code?
> Now I'd be curious to see
> if what you need can be worked out with the \temp... \meaning procedure,
> which looks more general than \IsInteger.



Below is my code.  It is an excerpt from a macro \fullref
for generating references to labels; in these references, I
want to include page number if and only if page number on
which the label was defined is at least two pages back or
one page forward relative to the current page.  (For each
defined label `label' my macros also define label
`label.pg', which \fullref uses).  See for yourself
(parameter #1 is label's name; \fullref at IsInteger is the
notorious \IsInteger):


  % See if we need to include page reference.  We do so only if label's page
  % number is at least two pages back or one page forward of the current page.
  % Of course, this still can inappropriately omit page reference in a reference
  % placed on previous/next page to the page it was defined on, in case the text
  % rolls over from another page during page breaking of a paragraph; but it is
  % better than nothing
  \let\fullref at pg\relax
  % We cannot call eplain's \refn directly to get the page number out of
  % label's definition, because \refn makes dummy definitions for undefined
  % labels.  To find out if it is really a number, we use \fullref at IsInteger
  \edef\fullref at refn{\refn{#1.pg}}%
  \if\fullref at IsInteger{\fullref at refn}% what we get is really the page number
    \count@=\refn{#1.pg}\relax % make sure the number ends here
    \ifnum\count@<\pageno % current page is at least 1 page forward
      \xdef\fullref at pg{pg.\thinspace\the\count@}%
    \else
      \advance\count@ by\m at ne % decrement
      \ifnum\count@>\pageno % current page is at least 2 pages back
        \advance\count@ by\@ne
        \xdef\fullref at pg{pg.\thinspace\the\count@}%
    \fi\fi
  \fi


Best regards,
Oleg Katsitadze



More information about the tex-eplain mailing list