[Tuglist] Printing c@\@captype.

David Kastrup tuglist@tug.org.in
13 Jun 2002 13:06:07 +0200


Manoj K N <knm@india.ti.com> writes:

> I was trying to print the value of the counter referred to by \@captype,
> and I used the following line, which gave me correct results.
> 
> \@arabic\csname c@\@captype\endcsname
> 
> Is this a good way of doing this?

No.  It only works by accident.  \@arabic is a macro taking one
argument which in this case is \csname.  It is only because the
definition \@arabic happens to end with #1 that not everything is
going up in flames.

What is wrong with using \arabic{\@captype} ?

> In other words, whenever we want to access the counter pointed to by
> a macro, is this how we do it?

No.  If you want the numbers output, use \arabic.  If you want to
access the value of a counter (for example, when assigning to another
counter), use \value{\@captype}.  If you are on a token saving spree,
\value\@captype will do fine, also.  LaTeX provides you with an
interface for accessing and printing counters.  There is no reason not
to use it.

In the case where instead of \@captype (a single token) you have an
actual name, such as "page", you can save tokens by writing \c@page
instead of \value{page}, and \@arabic\c@page instead of
\arabic{page}, since "{page}" are 6 separate character tokens while
\c@page is a single token.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: David.Kastrup@t-online.de