# [texhax] currentlabel and usebox

Francesca De Angeli fdeangeli at gmail.com
Thu Sep 7 19:36:32 CEST 2006

Hi,

I would like to redefine the current label of a new command using the
value of a savebox and a counter. My first guess would have been the
following:

--------
\newcommand{\newreqtype}[1]{\sbox{\reqsbox}{\bfseries#1}\setcounter
{req}{0}}

\newcommand{\req}[]{
...
\def\@currentlabel
{\csname p at req \endcsname \usebox{\reqsbox} -\thereq}%
}
--------

This does not run. If I substitute

\usebox{\reqsbox}

in the definition of currentlabel with

\leavevmode \copy \reqsbox \relax

it runs but unfortunaly the label assigned to each "req" is wrong.
For instance if I have in my tex file:

-------
\newreqtype{S-GEN}

..... \ref{req:t-perf:1} ...

\newreqtype{T-PERF}

\req{}{}...{}\label{req:t-perf:1}
--------

the resulting label is S-GEN-1 instead of T-PERF-1. The counter is
assigned correctly (I checked in the case of more than one "req"
defined), but the content of the saved box is the one defined where
the \ref{} command is used and not the \label{} one.

I would greatly appreciate your help!
Please do not hesitate contacting me if my problem is not made enough
clear.

Francesca
--
^-^
(o o)
v
(/   \)
****^*^***************************************************************
Francesca De Angeli                         E-mail: fda at ast.cam.ac.uk
Institute of Astronomy
University of Cambridge