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

martin f krafft madduck at madduck.net
Sat May 17 11:47:55 CEST 2008

Hey, thanks for taking the time to respond!

also sprach Philip TAYLOR (Ret'd) <P.Taylor at Rhul.Ac.Uk> [2008.05.16.2158 +0100]:
> 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.

Okay, this helps, and I got it working in a test case, which
I attached. The idea is that moving around a lot of text and having
subsubsections unnumbered invariably causes stuff like

  1.2.3 A section

  Bla bla as I will show in \ref{sub} bla bla

  Subsection title \label{sub}

  Bla bla

Which then turns into the silly

  1.2.3 A section

  Bla bla as I will show in 1.2.3 bla bla

Thus, I was thinking to compare the expanded ref with \the* and use
pagerefs instead, leaving the rest of the magic up to varioref. I'd
love to be shown a better solution, because once I get this working,
I'll need to deal with the fact that then stuff like

  "in 1.2.3"

will suddenly become

  "in page 4"

which is also stupid.

I've also brought up this issue before on texhax, but it's been so
long that I decided to start from scratch and somehow ended up doing
so on tug! :)

>> \edef \theref {\ref {b}}

So unfortunately, in my complex thesis document, when I use the
attached refs.sty, which now uses \edef to expand the rvalue,
latex (texlive) dies on the first occurrence of any of the \?ref{}

! 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

If I change back to using \def instead of \edef on line 6 of
refs.sty, then stuff goes back to normal.

This leaves me completely clueless.

Thanks for your time and help!

martin | http://madduck.net/ | http://two.sentenc.es/
"be the change you want to see in the world"
                                                     -- mahatma gandhi
spamtraps: madduck.bogus at madduck.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: refs.sty
Type: text/x-tex
Size: 3044 bytes
Desc: not available
Url : http://tug.org/pipermail/texhax/attachments/20080517/bd469164/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.tex
Type: text/x-tex
Size: 328 bytes
Desc: not available
Url : http://tug.org/pipermail/texhax/attachments/20080517/bd469164/attachment-0001.bin 
-------------- 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/20080517/bd469164/attachment-0002.bin 

More information about the texhax mailing list