[texhax] How to dereference a \ref in a command definition?

Philip TAYLOR (Ret'd) P.Taylor at Rhul.Ac.Uk
Fri May 16 22:58:58 CEST 2008


You probably need an \edef.  It's not entirely
clear what you're up to, but the following
fragment may illustrate the use of \edef for
dererencing \ref s.

> \documentclass {article}
> \begin {document}
> \section {one}
> \subsection {a}
> \subsection {b}
> \label {b}
> \section {two}
> \subsection {a}
> \subsection {b}
> \edef \theref {\ref {b}}
> \message {\meaning \theref}
> \end {document}

Philip TAYLOR

--------

martin f krafft wrote:

> Hello,
> 
> I am trying to write a command to manipulate some section
> references. My problem is that when I pass it something like
> 
>   \ref{mysection}
> 
> in #1, then \meaning{#2} tells me it's
> 
>   \protect\ref{mysection}
> 
> If I define a variable with that value (I am probably not using the
> right terms here...),
> 
>   \def\myref{#2}
> 
> then I can get rid of the \protect and \meaning\myref gives:
> 
>   \ref{mysection}
> 
> What I would really want/need at this stage is the section ref
> "unpacked", so replaced with its number, e.g. 4.1.2.
> 
> How can I achieve this?


More information about the texhax mailing list