# [texhax] in-section references

Sun Jan 28 16:41:59 CET 2007

Thanks to Tom's bootstrapping help, I now whacked up the code down
below and combined it with varioref. I can now do this:

See \vrref{section}{secA}
would become either of:
See section 1.2.3        (ref a different section)
See the next page        (near ref to same section)
See page 5               (far ref to smae section)

This works nicely. The only thing I have left to do now is to deal
with stuff like "In \vrref{section}{secB}", which could become "In
the next page". Obviously, I'd want that to be "on the next page".

The ideal but possibly also most hackish way would be to make text
figure out the word immediately before the \vrref call and to
replace in with on and In with On for in-section references. I am
not sure this is possible.

Another solution might be through the use of optional arguments,
like:

\vrref[In][On]{section}{secA}

but I don't like this at all really.

Any ideas?

\newcommand{\rrefx}[3]{%
\edef\curpart\thepart%
\edef\curchap\thechapter%
\edef\cursec\thesection%
\edef\cursubsec\thesubsection%
\edef\cursubsubsec\thesubsubsection%
\edef\curref#2%
\def\refsame{#3}%
\def\refother{#1~#2}%
\ifx\curref\curpart\refsame%
\else\ifx\curref\curchap\refsame%
\else\ifx\curref\cursec\refsame%
\else\ifx\curref\cursubsec\refsame%
\else\ifx\curref\cursubsubsec\refsame%
\else\refother%
\fi%
\fi%
\fi%
\fi%
\fi%
}%
\usepackage{varioref}
\def\reftextfaceafter {the \reftextvario{facing}{next} page}%
\def\reftextfacebefore{the \reftextvario{facing}{preceding} page}%
\def\reftextafter     {the \reftextvario{following}{next} page}%
\def\reftextbefore    {the \reftextvario{preceding}{previous} page}%
\def\reftextcurrent   {\reftextvario{this}{the current} page}%
\def\reftextfaraway#1{page~\pageref{#1}}%
\def\reftextpagerange#1#2{pages~\pageref{#1}--\pageref{#2}}%
\newcommand{\vrref}[2]{\rrefx{#1}{\ref{#2}}{\vpageref{#2}}}

--
martin;              (greetings from the heart of the sun.)
\____ echo mailto: !#^."<*>"|tr "<*> mailto:" net at madduck

"if a packet hits a pocket on a socket on a port, and the bus is
interrupted at a very last resort, and the access of the memory makes
your floppy disk abort, then the socket packet pocket has an error to
report."
-- <speedstream>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature (GPG/PGP)
Url : http://tug.org/pipermail/texhax/attachments/20070128/08227201/attachment.bin