TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to have access to the number associated to a box by giving its control sequence. This control sequence is defined by \newbox using \chardef so a "control sequence box" expands to something like \char"1A. I'd like to get that hexadecimal 1A. Here is what I did so far.






The \detokenize is there to take care of \catcode change due to the use of \meaning in \printboxnumber. Unfortunately, I get

! Use of \stripchar doesn't match its definition.
<inserted text> \char"
l.13 \printboxnumber\mybox

What's wrong?

share|improve this question
up vote 4 down vote accepted

\detokenize{\char"} results in \char " (with a space after the control sequence name); you need \string:


The second \string is in case babel is used. The \begingroup-\endgroup is to avoid leaving \temp defined.

The decimal representation can be obtained simply by \number\mybox.

share|improve this answer
\number\mybox... Good exercise anyway :-) Thanks for pointing out the \detokenize subtlety. – cjorssen Oct 27 '11 at 13:37
Every \chardef or \mathchardef token can be used when TeX is looking for a <number>. For example, the constant \@one, that is often used in packages, is defined as \chardef\@ne=1. – egreg Oct 27 '11 at 17:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.