[texhax] in-section references

martin f krafft madduck at madduck.net
Fri Sep 28 20:21:07 CEST 2007


Since this is eight months old, I include the full text:

also sprach Martin F Krafft <madduck at madduck.net> [2007.01.28.1541 +0000]:
> 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}}}

I thought this worked nicely, but now I am finding that for some
strange reason, the first \ifx always returns true; if I comment it
out, then the next one will be true.

I checked with simply "printf" debugging, and while \curref may be
e.g. 42 and \curchap is 3,

  \ifx\curref\curchap\refsame
  \else\refother\fi

will print \refsame instead of \refother. This is really
disconcerting, especially since I am sure it worked when I sent the
post I quoted above in january.

Does anyone have a clue what could be going on? I am at a loss and
about to go bonkers over this.

Cheers,

-- 
martin;              (greetings from the heart of the sun.)
  \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net at madduck
 
"a kiss may ruin a human life."
                                                        -- oscar wilde
 
spamtraps: madduck.bogus at madduck.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature (see http://martin-krafft.net/gpg/)
Url : http://tug.org/pipermail/texhax/attachments/20070928/211f480b/attachment.bin 


More information about the texhax mailing list