[texhax] How to dereference a \ref in a command definition?
Morten Høgholm
morten.hoegholm at gmail.com
Sat May 17 16:04:00 CEST 2008
On Sat, 17 May 2008 13:45:54 +0200, martin f krafft wrote:
> also sprach Morten Høgholm <morten.hoegholm at gmail.com> [2008.05.17.1208
> +0100]:
>> \getrefnumber from the refcount package.
>
> Ah, nice. Except in my thesis, I still get
>
> ! Use of \\aref doesn't match its definition.
> \@ifnextchar ... \reserved at d =#1\def \reserved at a {
> #2}\def \reserved at b
> {#3}\f...
> l.52 ... documents, the \ac{DFSG} (see \aref{dfsg}
> ), a part of \D{}'s
>
> No idea what this is about... and no idea how to recreate that in
> the test case...
I did the following alterations:
\newcommand{\rrefx}[3]{%
\protected at edef\curchapter{\thechapter}% removed \hbox{}
\protected at edef\cursection{\thesection}% ditto
\protected at edef\cursubsection{\thesubsection}% ditto
\protected at edef\cursubsubsection{\thesubsubsection}% ditto
\protected at edef\curref{#2}% here: never raw \edef in LaTeX!
\def\refsame{#3}%
\def\refother{#1~#2}%
\typeout {DEBUG: curref: \meaning\curref}
\typeout {DEBUG: cursec: \meaning\cursubsection}
\ifx\curchapter\curref\refsame%
\else\ifx\cursection\curref\refsame%
\else\ifx\cursubsection\curref\refsame%
\else\ifx\cursubsubsection\curref\refsame%
\else\refother%
\fi%
\fi%
\fi%
\fi%
}
\newcommand{\rref}[2]{\rrefx{#1}{\getrefnumber{#2}}{\pageref{#2}}}
\newcommand{\vrref}[2]{\rrefx{#1}{\getrefnumber{#2}}{\vpageref{#2}}}
--
Morten
More information about the texhax
mailing list